@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_STATS_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_STATS')) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getTotalViews() |
104 | 104 | { |
105 | - $sql = 'SELECT sum(topic_views) FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' '; |
|
105 | + $sql = 'SELECT sum(topic_views) FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' '; |
|
106 | 106 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
107 | 107 | return null; |
108 | 108 | } |
@@ -17,97 +17,97 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_STATS_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_STATS')) { |
20 | - define('NEWBB_FUNCTIONS_STATS', 1); |
|
20 | + define('NEWBB_FUNCTIONS_STATS', 1); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return mixed |
|
24 | - */ |
|
25 | - function newbbGetStats() |
|
26 | - { |
|
27 | - /** @var Newbb\StatsHandler $statsHandler */ |
|
28 | - $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
29 | - $stats = $statsHandler->getStats(); |
|
22 | + /** |
|
23 | + * @return mixed |
|
24 | + */ |
|
25 | + function newbbGetStats() |
|
26 | + { |
|
27 | + /** @var Newbb\StatsHandler $statsHandler */ |
|
28 | + $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
29 | + $stats = $statsHandler->getStats(); |
|
30 | 30 | |
31 | - return $stats; |
|
32 | - } |
|
31 | + return $stats; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $id |
|
36 | - * @param $type |
|
37 | - * @param int $increment |
|
38 | - * @return mixed |
|
39 | - */ |
|
40 | - function newbbUpdateStats($id, $type, $increment = 1) |
|
41 | - { |
|
42 | - /** @var Newbb\StatsHandler $statsHandler */ |
|
43 | - $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
34 | + /** |
|
35 | + * @param $id |
|
36 | + * @param $type |
|
37 | + * @param int $increment |
|
38 | + * @return mixed |
|
39 | + */ |
|
40 | + function newbbUpdateStats($id, $type, $increment = 1) |
|
41 | + { |
|
42 | + /** @var Newbb\StatsHandler $statsHandler */ |
|
43 | + $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats'); |
|
44 | 44 | |
45 | - return $statsHandler->update($id, $type, $increment); |
|
46 | - } |
|
45 | + return $statsHandler->update($id, $type, $increment); |
|
46 | + } |
|
47 | 47 | |
48 | - /* |
|
48 | + /* |
|
49 | 49 | * Gets the total number of topics in a form |
50 | 50 | */ |
51 | - /** |
|
52 | - * @param string $forum_id |
|
53 | - * @return mixed |
|
54 | - */ |
|
55 | - function getTotalTopics($forum_id = '') |
|
56 | - { |
|
57 | - /** @var Newbb\TopicHandler $topicHandler */ |
|
58 | - $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
59 | - $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
60 | - if ($forum_id) { |
|
61 | - $criteria->add(new \Criteria('forum_id', (int)$forum_id)); |
|
62 | - } |
|
51 | + /** |
|
52 | + * @param string $forum_id |
|
53 | + * @return mixed |
|
54 | + */ |
|
55 | + function getTotalTopics($forum_id = '') |
|
56 | + { |
|
57 | + /** @var Newbb\TopicHandler $topicHandler */ |
|
58 | + $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
59 | + $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
60 | + if ($forum_id) { |
|
61 | + $criteria->add(new \Criteria('forum_id', (int)$forum_id)); |
|
62 | + } |
|
63 | 63 | |
64 | - return $topicHandler->getCount($criteria); |
|
65 | - } |
|
64 | + return $topicHandler->getCount($criteria); |
|
65 | + } |
|
66 | 66 | |
67 | - /* |
|
67 | + /* |
|
68 | 68 | * Returns the total number of posts in the whole system, a forum, or a topic |
69 | 69 | * Also can return the number of users on the system. |
70 | 70 | */ |
71 | - /** |
|
72 | - * @param int $id |
|
73 | - * @param string $type |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - function getTotalPosts($id = 0, $type = 'all') |
|
77 | - { |
|
78 | - /** @var Newbb\PostHandler $postHandler */ |
|
79 | - $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
80 | - $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
81 | - switch ($type) { |
|
82 | - case 'forum': |
|
83 | - if ($id > 0) { |
|
84 | - $criteria->add(new \Criteria('forum_id', (int)$id)); |
|
85 | - } |
|
86 | - break; |
|
87 | - case 'topic': |
|
88 | - if ($id > 0) { |
|
89 | - $criteria->add(new \Criteria('topic_id', (int)$id)); |
|
90 | - } |
|
91 | - break; |
|
92 | - case 'all': |
|
93 | - default: |
|
94 | - break; |
|
95 | - } |
|
71 | + /** |
|
72 | + * @param int $id |
|
73 | + * @param string $type |
|
74 | + * @return mixed |
|
75 | + */ |
|
76 | + function getTotalPosts($id = 0, $type = 'all') |
|
77 | + { |
|
78 | + /** @var Newbb\PostHandler $postHandler */ |
|
79 | + $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
80 | + $criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>')); |
|
81 | + switch ($type) { |
|
82 | + case 'forum': |
|
83 | + if ($id > 0) { |
|
84 | + $criteria->add(new \Criteria('forum_id', (int)$id)); |
|
85 | + } |
|
86 | + break; |
|
87 | + case 'topic': |
|
88 | + if ($id > 0) { |
|
89 | + $criteria->add(new \Criteria('topic_id', (int)$id)); |
|
90 | + } |
|
91 | + break; |
|
92 | + case 'all': |
|
93 | + default: |
|
94 | + break; |
|
95 | + } |
|
96 | 96 | |
97 | - return $postHandler->getCount($criteria); |
|
98 | - } |
|
97 | + return $postHandler->getCount($criteria); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return null |
|
102 | - */ |
|
103 | - function getTotalViews() |
|
104 | - { |
|
105 | - $sql = 'SELECT sum(topic_views) FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' '; |
|
106 | - if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
107 | - return null; |
|
108 | - } |
|
109 | - list($total) = $GLOBALS['xoopsDB']->fetchRow($result); |
|
100 | + /** |
|
101 | + * @return null |
|
102 | + */ |
|
103 | + function getTotalViews() |
|
104 | + { |
|
105 | + $sql = 'SELECT sum(topic_views) FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' '; |
|
106 | + if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
|
107 | + return null; |
|
108 | + } |
|
109 | + list($total) = $GLOBALS['xoopsDB']->fetchRow($result); |
|
110 | 110 | |
111 | - return $total; |
|
112 | - } |
|
111 | + return $total; |
|
112 | + } |
|
113 | 113 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13 | 13 | |
14 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
14 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
15 | 15 | define('NEWBB_FUNCTIONS_LANGUAGE_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_LANGUAGE')) { |
@@ -15,22 +15,22 @@ |
||
15 | 15 | define('NEWBB_FUNCTIONS_LANGUAGE_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_LANGUAGE')) { |
18 | - define('NEWBB_FUNCTIONS_LANGUAGE', 1); |
|
18 | + define('NEWBB_FUNCTIONS_LANGUAGE', 1); |
|
19 | 19 | |
20 | - /** |
|
21 | - * @param $page |
|
22 | - * @param string $dirname |
|
23 | - * @return bool |
|
24 | - */ |
|
25 | - function newbbLoadLanguage($page, $dirname = 'newbb') |
|
26 | - { |
|
27 | - $page = str_replace('..', '', $page); |
|
28 | - if (!@require_once $GLOBALS['xoops']->path("modules/{$dirname}/{$GLOBALS['xoopsConfig']['language']}/{$language}.php")) { |
|
29 | - if (!@require_once $GLOBALS['xoops']->path("modules/{$dirname}/language/{$language}.php")) { |
|
30 | - return false; |
|
31 | - } |
|
32 | - } |
|
20 | + /** |
|
21 | + * @param $page |
|
22 | + * @param string $dirname |
|
23 | + * @return bool |
|
24 | + */ |
|
25 | + function newbbLoadLanguage($page, $dirname = 'newbb') |
|
26 | + { |
|
27 | + $page = str_replace('..', '', $page); |
|
28 | + if (!@require_once $GLOBALS['xoops']->path("modules/{$dirname}/{$GLOBALS['xoopsConfig']['language']}/{$language}.php")) { |
|
29 | + if (!@require_once $GLOBALS['xoops']->path("modules/{$dirname}/language/{$language}.php")) { |
|
30 | + return false; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - return true; |
|
35 | - } |
|
34 | + return true; |
|
35 | + } |
|
36 | 36 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13 | 13 | |
14 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
14 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
15 | 15 | define('NEWBB_FUNCTIONS_TIME_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_TIME')) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | // irmtfan no option when no selected value |
77 | 77 | $forum_selection_since .= '<option value="">--------</option>'; |
78 | 78 | foreach ($select_array as $since) { |
79 | - $forum_selection_since .= '<option value="' . $since . '"' . (($selected == $since) ? ' selected="selected"' : '') . '>'; |
|
79 | + $forum_selection_since .= '<option value="'.$since.'"'.(($selected == $since) ? ' selected="selected"' : '').'>'; |
|
80 | 80 | // START irmtfan functional since 0 and 365 |
81 | 81 | switch ($since) { |
82 | 82 | case 0: |
@@ -15,106 +15,106 @@ |
||
15 | 15 | define('NEWBB_FUNCTIONS_TIME_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_TIME')) { |
18 | - define('NEWBB_FUNCTIONS_TIME', 1); |
|
18 | + define('NEWBB_FUNCTIONS_TIME', 1); |
|
19 | 19 | |
20 | - /** |
|
21 | - * Function to convert UNIX time to formatted time string |
|
22 | - * @param $time |
|
23 | - * @param string $format |
|
24 | - * @param string $timeoffset |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - function newbbFormatTimestamp($time, $format = 'c', $timeoffset = '') |
|
28 | - { |
|
29 | - xoops_loadLanguage('locale'); |
|
30 | - $newbbConfig = newbbLoadConfig(); |
|
20 | + /** |
|
21 | + * Function to convert UNIX time to formatted time string |
|
22 | + * @param $time |
|
23 | + * @param string $format |
|
24 | + * @param string $timeoffset |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + function newbbFormatTimestamp($time, $format = 'c', $timeoffset = '') |
|
28 | + { |
|
29 | + xoops_loadLanguage('locale'); |
|
30 | + $newbbConfig = newbbLoadConfig(); |
|
31 | 31 | |
32 | - $format = strtolower($format); |
|
33 | - if ('reg' === $format || '' === $format) { |
|
34 | - $format = 'c'; |
|
35 | - } |
|
36 | - if (('custom' === $format || 'c' === $format) && !empty($newbbConfig['formatTimestamp_custom'])) { |
|
37 | - $format = $newbbConfig['formatTimestamp_custom']; |
|
38 | - } |
|
32 | + $format = strtolower($format); |
|
33 | + if ('reg' === $format || '' === $format) { |
|
34 | + $format = 'c'; |
|
35 | + } |
|
36 | + if (('custom' === $format || 'c' === $format) && !empty($newbbConfig['formatTimestamp_custom'])) { |
|
37 | + $format = $newbbConfig['formatTimestamp_custom']; |
|
38 | + } |
|
39 | 39 | |
40 | - return XoopsLocal::formatTimestamp($time, $format, $timeoffset); |
|
41 | - } |
|
40 | + return XoopsLocal::formatTimestamp($time, $format, $timeoffset); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param int $selected |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - function newbbSinceSelectBox($selected = 100) |
|
48 | - { |
|
49 | - $newbbConfig = newbbLoadConfig(); |
|
50 | - // irmtfan - new method to get user inputs |
|
51 | - preg_match_all('/-?\d+/', $newbbConfig['since_options'], $match); |
|
52 | - $select_array = array_unique($match[0]); |
|
53 | - //$select_array = explode(',', $newbbConfig['since_options']); |
|
54 | - //$select_array = array_map('trim', $select_array); |
|
55 | - // irmtfan - if the array is empty do not show selection box |
|
56 | - if (!(bool)$select_array) { |
|
57 | - $since = $newbbConfig['since_default']; |
|
58 | - switch ($since) { |
|
59 | - case 0: |
|
60 | - $forum_since = _MD_NEWBB_BEGINNING; |
|
61 | - break; |
|
62 | - case 365: |
|
63 | - $forum_since = _MD_NEWBB_THELASTYEAR; |
|
64 | - break; |
|
65 | - default: |
|
66 | - if ($since > 0) { |
|
67 | - $forum_since = sprintf(_MD_NEWBB_FROMLASTDAYS, $since); |
|
68 | - } else { |
|
69 | - $forum_since = sprintf(_MD_NEWBB_FROMLASTHOURS, abs($since)); |
|
70 | - } |
|
71 | - } |
|
43 | + /** |
|
44 | + * @param int $selected |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + function newbbSinceSelectBox($selected = 100) |
|
48 | + { |
|
49 | + $newbbConfig = newbbLoadConfig(); |
|
50 | + // irmtfan - new method to get user inputs |
|
51 | + preg_match_all('/-?\d+/', $newbbConfig['since_options'], $match); |
|
52 | + $select_array = array_unique($match[0]); |
|
53 | + //$select_array = explode(',', $newbbConfig['since_options']); |
|
54 | + //$select_array = array_map('trim', $select_array); |
|
55 | + // irmtfan - if the array is empty do not show selection box |
|
56 | + if (!(bool)$select_array) { |
|
57 | + $since = $newbbConfig['since_default']; |
|
58 | + switch ($since) { |
|
59 | + case 0: |
|
60 | + $forum_since = _MD_NEWBB_BEGINNING; |
|
61 | + break; |
|
62 | + case 365: |
|
63 | + $forum_since = _MD_NEWBB_THELASTYEAR; |
|
64 | + break; |
|
65 | + default: |
|
66 | + if ($since > 0) { |
|
67 | + $forum_since = sprintf(_MD_NEWBB_FROMLASTDAYS, $since); |
|
68 | + } else { |
|
69 | + $forum_since = sprintf(_MD_NEWBB_FROMLASTHOURS, abs($since)); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return $forum_since; |
|
74 | - } |
|
75 | - $forum_selection_since = '<select class="form-control" name="since" id="since">'; |
|
76 | - // irmtfan no option when no selected value |
|
77 | - $forum_selection_since .= '<option value="">--------</option>'; |
|
78 | - foreach ($select_array as $since) { |
|
79 | - $forum_selection_since .= '<option value="' . $since . '"' . (($selected == $since) ? ' selected="selected"' : '') . '>'; |
|
80 | - // START irmtfan functional since 0 and 365 |
|
81 | - switch ($since) { |
|
82 | - case 0: |
|
83 | - $forum_selection_since .= _MD_NEWBB_BEGINNING; |
|
84 | - break; |
|
85 | - case 365: |
|
86 | - $forum_selection_since .= _MD_NEWBB_THELASTYEAR; |
|
87 | - break; |
|
88 | - default: |
|
89 | - if ($since > 0) { |
|
90 | - $forum_selection_since .= sprintf(_MD_NEWBB_FROMLASTDAYS, $since); |
|
91 | - } else { |
|
92 | - $forum_selection_since .= sprintf(_MD_NEWBB_FROMLASTHOURS, abs($since)); |
|
93 | - } |
|
94 | - } |
|
95 | - // END irmtfan functional since 0 and 365 |
|
96 | - $forum_selection_since .= '</option>'; |
|
97 | - } |
|
98 | - // irmtfan remove hardcodes |
|
99 | - //$forum_selection_since .= '<option value="365"'.(($selected === 365) ? ' selected="selected"' : '').'>'._MD_NEWBB_THELASTYEAR.'</option>'; |
|
100 | - //$forum_selection_since .= '<option value="0"'.(($selected === 0) ? ' selected="selected"' : '').'>'._MD_NEWBB_BEGINNING.'</option>'; |
|
101 | - $forum_selection_since .= '</select>'; |
|
73 | + return $forum_since; |
|
74 | + } |
|
75 | + $forum_selection_since = '<select class="form-control" name="since" id="since">'; |
|
76 | + // irmtfan no option when no selected value |
|
77 | + $forum_selection_since .= '<option value="">--------</option>'; |
|
78 | + foreach ($select_array as $since) { |
|
79 | + $forum_selection_since .= '<option value="' . $since . '"' . (($selected == $since) ? ' selected="selected"' : '') . '>'; |
|
80 | + // START irmtfan functional since 0 and 365 |
|
81 | + switch ($since) { |
|
82 | + case 0: |
|
83 | + $forum_selection_since .= _MD_NEWBB_BEGINNING; |
|
84 | + break; |
|
85 | + case 365: |
|
86 | + $forum_selection_since .= _MD_NEWBB_THELASTYEAR; |
|
87 | + break; |
|
88 | + default: |
|
89 | + if ($since > 0) { |
|
90 | + $forum_selection_since .= sprintf(_MD_NEWBB_FROMLASTDAYS, $since); |
|
91 | + } else { |
|
92 | + $forum_selection_since .= sprintf(_MD_NEWBB_FROMLASTHOURS, abs($since)); |
|
93 | + } |
|
94 | + } |
|
95 | + // END irmtfan functional since 0 and 365 |
|
96 | + $forum_selection_since .= '</option>'; |
|
97 | + } |
|
98 | + // irmtfan remove hardcodes |
|
99 | + //$forum_selection_since .= '<option value="365"'.(($selected === 365) ? ' selected="selected"' : '').'>'._MD_NEWBB_THELASTYEAR.'</option>'; |
|
100 | + //$forum_selection_since .= '<option value="0"'.(($selected === 0) ? ' selected="selected"' : '').'>'._MD_NEWBB_BEGINNING.'</option>'; |
|
101 | + $forum_selection_since .= '</select>'; |
|
102 | 102 | |
103 | - return $forum_selection_since; |
|
104 | - } |
|
103 | + return $forum_selection_since; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @param int $since |
|
108 | - * @return int |
|
109 | - */ |
|
110 | - function newbbGetSinceTime($since = 100) |
|
111 | - { |
|
112 | - // irmtfan bad coding |
|
113 | - //if ($since==1000) return 0; |
|
114 | - if ($since > 0) { |
|
115 | - return (int)$since * 24 * 3600; |
|
116 | - } else { |
|
117 | - return (int)abs($since) * 3600; |
|
118 | - } |
|
119 | - } |
|
106 | + /** |
|
107 | + * @param int $since |
|
108 | + * @return int |
|
109 | + */ |
|
110 | + function newbbGetSinceTime($since = 100) |
|
111 | + { |
|
112 | + // irmtfan bad coding |
|
113 | + //if ($since==1000) return 0; |
|
114 | + if ($since > 0) { |
|
115 | + return (int)$since * 24 * 3600; |
|
116 | + } else { |
|
117 | + return (int)abs($since) * 3600; |
|
118 | + } |
|
119 | + } |
|
120 | 120 | } |
@@ -38,5 +38,5 @@ |
||
38 | 38 | /** |
39 | 39 | * @return array |
40 | 40 | */ |
41 | -require_once __DIR__ . '/functions.config.php'; |
|
42 | -require_once __DIR__ . '/functions.session.php'; |
|
41 | +require_once __DIR__.'/functions.config.php'; |
|
42 | +require_once __DIR__.'/functions.session.php'; |
@@ -31,7 +31,7 @@ |
||
31 | 31 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
32 | 32 | |
33 | 33 | if (defined('NEWBB_FUNCTIONS_INI')) { |
34 | - return; |
|
34 | + return; |
|
35 | 35 | } |
36 | 36 | define('NEWBB_FUNCTIONS_INI', 1); |
37 | 37 |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | |
32 | 32 | use Xmf\Request; |
33 | 33 | |
34 | -require_once __DIR__ . '/header.php'; |
|
34 | +require_once __DIR__.'/header.php'; |
|
35 | 35 | require_once $GLOBALS['xoops']->path('class/template.php'); |
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 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $validForums = array_intersect($forums, $validForums); |
60 | 60 | } elseif ($category > 0) { |
61 | 61 | $crit_top = new \CriteriaCompo(new \Criteria('cat_id', $category)); |
62 | - $crit_top->add(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN')); |
|
62 | + $crit_top->add(new \Criteria('forum_id', '('.implode(', ', $validForums).')', 'IN')); |
|
63 | 63 | $forums_top = $forumHandler->getIds($crit_top); |
64 | 64 | $validForums = array_intersect($forums_top, $validForums); |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $forumSet = implode(',', $validForums); |
72 | 72 | |
73 | 73 | $charset = 'UTF-8'; |
74 | -header('Content-Type:text/xml; charset=' . $charset); |
|
74 | +header('Content-Type:text/xml; charset='.$charset); |
|
75 | 75 | |
76 | 76 | $tpl = new \XoopsTpl(); |
77 | 77 | $tpl->caching = 2; |
@@ -84,25 +84,25 @@ discard block |
||
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'; |
|
87 | + require_once __DIR__.'/include/functions.time.php'; |
|
88 | 88 | |
89 | 89 | // /** @var Newbb\XmlrssHandler $xmlrssHandler */ |
90 | 90 | // $xmlrssHandler = Newbb\Helper::getInstance()->getHandler('Xmlrss'); |
91 | 91 | $rss = $xmlrssHandler->create(); |
92 | 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')); |
|
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 | 96 | $rss->setVarRss('channel_lastbuild', formatTimestamp(time(), 'rss')); |
97 | 97 | $rss->channel_webmaster = $GLOBALS['xoopsConfig']['adminmail']; |
98 | 98 | $rss->channel_editor = $GLOBALS['xoopsConfig']['adminmail']; |
99 | 99 | $rss->setVarRss('channel_category', $xoopsModule->getVar('name')); |
100 | - $rss->channel_generator = 'NewBB ' . $xoopsModule->getInfo('version'); |
|
100 | + $rss->channel_generator = 'NewBB '.$xoopsModule->getInfo('version'); |
|
101 | 101 | $rss->channel_language = _LANGCODE; |
102 | 102 | $rss->xml_encoding = $charset; |
103 | - $rss->image_url = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image'); |
|
103 | + $rss->image_url = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/'.$xoopsModule->getInfo('image'); |
|
104 | 104 | |
105 | - $dimension = @getimagesize($GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image'))); |
|
105 | + $dimension = @getimagesize($GLOBALS['xoops']->path('modules/'.$xoopsModule->getVar('dirname').'/'.$xoopsModule->getInfo('image'))); |
|
106 | 106 | if (empty($dimension[0])) { |
107 | 107 | $width = 88; |
108 | 108 | } else { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $rss->max_items = $GLOBALS['xoopsModuleConfig']['rss_maxitems']; |
120 | 120 | $rss->max_item_description = $GLOBALS['xoopsModuleConfig']['rss_maxdescription']; |
121 | 121 | |
122 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $validForums) . ')'; |
|
122 | + $forumCriteria = ' AND t.forum_id IN ('.implode(',', $validForums).')'; |
|
123 | 123 | unset($validForums); |
124 | 124 | $approveCriteria = ' AND t.approved = 1 AND p.approved = 1'; |
125 | 125 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | if (count($types) > 0) { |
170 | 170 | // /** @var Newbb\TypeHandler $typeHandler */ |
171 | 171 | // $typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
172 | - $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
172 | + $type_list = $typeHandler->getList(new \Criteria('type_id', '('.implode(', ', array_keys($types)).')', 'IN')); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | foreach ($rows as $topic) { |
@@ -184,16 +184,16 @@ discard block |
||
184 | 184 | } else { |
185 | 185 | $topic['uname'] = $topic['poster_name'] ? $myts->htmlSpecialChars($topic['poster_name']) : $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']); |
186 | 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"; |
|
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 | 190 | $description .= $myts->displayTarea($topic['post_text'], $topic['dohtml'], $topic['dosmiley'], $topic['doxcode'], $topic['dobr']); |
191 | - $label = _MD_NEWBB_BY . ' ' . $topic['uname']; |
|
191 | + $label = _MD_NEWBB_BY.' '.$topic['uname']; |
|
192 | 192 | $time = formatTimestamp($topic['post_time'], 'rss'); |
193 | - $link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $topic['post_id'] . ''; |
|
193 | + $link = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?post_id='.$topic['post_id'].''; |
|
194 | 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 . '\'>'; |
|
195 | + $link = XOOPS_URL.'/'.REAL_MODULE_NAME.'/viewtopic.php?post_id='.$topic['post_id'].''; |
|
196 | + $oldurl = '<a href=\''.$link.'\'>'; |
|
197 | 197 | $newurl = seo_urls($oldurl); |
198 | 198 | $newurl = str_replace('<a href=\'', '', $newurl); |
199 | 199 | $newurl = str_replace('\'>', '', $newurl); |
@@ -36,7 +36,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | // $sql .= " WHERE metakey='version' LIMIT 1"; |
35 | 35 | // $query = $GLOBALS['xoopsDB']->query($sql); |
36 | 36 | // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
37 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
37 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>".constant('CO_'.$moduleDirNameUpper.'_IMAGEINFO')."</legend>\n"; |
|
38 | 38 | $html .= "<div style='padding: 8px;'>\n"; |
39 | 39 | // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
40 | 40 | // $html .= "<br>\n"; |
41 | 41 | // $html .= "<br>\n"; |
42 | - $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
42 | + $html .= '<div>'.constant('CO_'.$moduleDirNameUpper.'_SPHPINI')."</div>\n"; |
|
43 | 43 | $html .= "<ul>\n"; |
44 | 44 | // |
45 | - $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
45 | + $gdlib = function_exists('gd_info') ? '<span style="color: green;">'.constant('CO_'.$moduleDirNameUpper.'_GDON').'</span>' : '<span style="color: red;">'.constant('CO_'.$moduleDirNameUpper.'_GDOFF').'</span>'; |
|
46 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_GDLIBSTATUS').$gdlib; |
|
47 | 47 | if (function_exists('gd_info')) { |
48 | 48 | if (true === ($gdlib = gd_info())) { |
49 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
49 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_GDLIBVERSION').'<b>'.$gdlib['GD Version'].'</b>'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | // |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
57 | 57 | // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
58 | 58 | // |
59 | - $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
59 | + $downloads = ini_get('file_uploads') ? '<span style="color: green;">'.constant('CO_'.$moduleDirNameUpper.'_ON').'</span>' : '<span style="color: red;">'.constant('CO_'.$moduleDirNameUpper.'_OFF').'</span>'; |
|
60 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_SERVERUPLOADSTATUS').$downloads; |
|
61 | 61 | // |
62 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
62 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_MAXUPLOADSIZE').' <b><span style="color: blue;">'.ini_get('upload_max_filesize')."</span></b>\n"; |
|
63 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_MAXPOSTSIZE').' <b><span style="color: blue;">'.ini_get('post_max_size')."</span></b>\n"; |
|
64 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_MEMORYLIMIT').' <b><span style="color: blue;">'.ini_get('memory_limit')."</span></b>\n"; |
|
65 | 65 | $html .= "</ul>\n"; |
66 | 66 | $html .= "<ul>\n"; |
67 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
67 | + $html .= '<li>'.constant('CO_'.$moduleDirNameUpper.'_SERVERPATH').' <b>'.XOOPS_ROOT_PATH."</b>\n"; |
|
68 | 68 | $html .= "</ul>\n"; |
69 | 69 | $html .= "<br>\n"; |
70 | - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
70 | + $html .= constant('CO_'.$moduleDirNameUpper.'_UPLOADPATHDSC')."\n"; |
|
71 | 71 | $html .= '</div>'; |
72 | 72 | $html .= '</fieldset><br>'; |
73 | 73 |
@@ -17,60 +17,60 @@ |
||
17 | 17 | */ |
18 | 18 | trait ServerStats |
19 | 19 | { |
20 | - /** |
|
21 | - * serverStats() |
|
22 | - * |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public static function getServerStats() |
|
26 | - { |
|
27 | - //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
28 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
29 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
30 | - xoops_loadLanguage('common', $moduleDirName); |
|
31 | - $html = ''; |
|
32 | - // $sql = 'SELECT metavalue'; |
|
33 | - // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
34 | - // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
35 | - // $query = $GLOBALS['xoopsDB']->query($sql); |
|
36 | - // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
37 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
38 | - $html .= "<div style='padding: 8px;'>\n"; |
|
39 | - // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
40 | - // $html .= "<br>\n"; |
|
41 | - // $html .= "<br>\n"; |
|
42 | - $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
43 | - $html .= "<ul>\n"; |
|
44 | - // |
|
45 | - $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | - if (function_exists('gd_info')) { |
|
48 | - if (true === ($gdlib = gd_info())) { |
|
49 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
50 | - } |
|
51 | - } |
|
52 | - // |
|
53 | - // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
54 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
55 | - // |
|
56 | - // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
57 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
58 | - // |
|
59 | - $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | - // |
|
62 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
65 | - $html .= "</ul>\n"; |
|
66 | - $html .= "<ul>\n"; |
|
67 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
68 | - $html .= "</ul>\n"; |
|
69 | - $html .= "<br>\n"; |
|
70 | - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
71 | - $html .= '</div>'; |
|
72 | - $html .= '</fieldset><br>'; |
|
20 | + /** |
|
21 | + * serverStats() |
|
22 | + * |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public static function getServerStats() |
|
26 | + { |
|
27 | + //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
28 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
29 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
30 | + xoops_loadLanguage('common', $moduleDirName); |
|
31 | + $html = ''; |
|
32 | + // $sql = 'SELECT metavalue'; |
|
33 | + // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
34 | + // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
35 | + // $query = $GLOBALS['xoopsDB']->query($sql); |
|
36 | + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
37 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
38 | + $html .= "<div style='padding: 8px;'>\n"; |
|
39 | + // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
40 | + // $html .= "<br>\n"; |
|
41 | + // $html .= "<br>\n"; |
|
42 | + $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
43 | + $html .= "<ul>\n"; |
|
44 | + // |
|
45 | + $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | + if (function_exists('gd_info')) { |
|
48 | + if (true === ($gdlib = gd_info())) { |
|
49 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
50 | + } |
|
51 | + } |
|
52 | + // |
|
53 | + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
54 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
55 | + // |
|
56 | + // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
57 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
58 | + // |
|
59 | + $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | + // |
|
62 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
65 | + $html .= "</ul>\n"; |
|
66 | + $html .= "<ul>\n"; |
|
67 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
68 | + $html .= "</ul>\n"; |
|
69 | + $html .= "<br>\n"; |
|
70 | + $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
71 | + $html .= '</div>'; |
|
72 | + $html .= '</fieldset><br>'; |
|
73 | 73 | |
74 | - return $html; |
|
75 | - } |
|
74 | + return $html; |
|
75 | + } |
|
76 | 76 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
14 | 14 | |
15 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
15 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
16 | 16 | |
17 | 17 | define('NEWBB_STATS_TYPE_TOPIC', 1); |
18 | 18 | define('NEWBB_STATS_TYPE_POST', 2); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - $sql = " UPDATE {$this->table}" |
|
81 | + $sql = " UPDATE {$this->table}" |
|
82 | 82 | . ' SET stats_value = CASE ' |
83 | 83 | . " WHEN time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) THEN stats_value + '{$increment}' " |
84 | 84 | . " ELSE '{$increment}' " |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $result = $this->db->queryF($sql); |
91 | 91 | $rows = $this->db->getAffectedRows(); |
92 | 92 | if (0 == $rows) { |
93 | - $sql = " INSERT INTO {$this->table}" |
|
93 | + $sql = " INSERT INTO {$this->table}" |
|
94 | 94 | . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
95 | 95 | . ' VALUES ' |
96 | 96 | . " ('0', '{$increment}', '{$type}', '" |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | foreach ($periods as $period) { |
148 | 148 | $_periods[] = array_search($period, $this->param['period']); |
149 | 149 | } |
150 | - $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' |
|
150 | + $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' |
|
151 | 151 | . " FROM {$this->table} " |
152 | 152 | . ' WHERE ' |
153 | 153 | . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) " |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | . implode(', ', array_map('intval', $ids)) |
157 | 157 | . ')') |
158 | 158 | . ' ' |
159 | - . (empty($_types) ? '' : 'AND stats_type IN (' . implode(', ', $_types) . ')') |
|
159 | + . (empty($_types) ? '' : 'AND stats_type IN ('.implode(', ', $_types).')') |
|
160 | 160 | . ' ' |
161 | - . (empty($_periods) ? '' : 'AND stats_period IN (' . implode(', ', $_periods) . ')'); |
|
161 | + . (empty($_periods) ? '' : 'AND stats_period IN ('.implode(', ', $_periods).')'); |
|
162 | 162 | $result = $this->db->query($sql); |
163 | 163 | |
164 | 164 | while (false !== ($row = $this->db->fetchArray($result))) { |
@@ -170,36 +170,36 @@ discard block |
||
170 | 170 | |
171 | 171 | public function reset() |
172 | 172 | { |
173 | - $this->db->queryF('TRUNCATE TABLE ' . $this->table); |
|
173 | + $this->db->queryF('TRUNCATE TABLE '.$this->table); |
|
174 | 174 | $now = time(); |
175 | 175 | $time_start = [ |
176 | 176 | 'day' => '%Y%j', |
177 | 177 | 'week' => '%Y%u', |
178 | 178 | 'month' => '%Y%m' |
179 | 179 | ]; |
180 | - $counts = []; |
|
180 | + $counts = []; |
|
181 | 181 | |
182 | - $sql = ' SELECT forum_id' . ' FROM ' . $this->db->prefix('newbb_forums'); |
|
182 | + $sql = ' SELECT forum_id'.' FROM '.$this->db->prefix('newbb_forums'); |
|
183 | 183 | $ret = $this->db->query($sql); |
184 | 184 | while (false !== (list($forum_id) = $this->db->fetchRow($ret))) { |
185 | - $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}"; |
|
185 | + $sql = ' SELECT COUNT(*), SUM(topic_views)'.' FROM '.$this->db->prefix('newbb_topics')." WHERE approved=1 AND forum_id = {$forum_id}"; |
|
186 | 186 | $result = $this->db->query($sql); |
187 | 187 | list($topics, $views) = $this->db->fetchRow($result); |
188 | 188 | $this->update($forum_id, 'topic', $topics); |
189 | 189 | $this->update($forum_id, 'view', $views); |
190 | 190 | |
191 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}"; |
|
191 | + $sql = ' SELECT COUNT(*)'.' FROM '.$this->db->prefix('newbb_topics')." WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}"; |
|
192 | 192 | $result = $this->db->query($sql); |
193 | 193 | list($digests) = $this->db->fetchRow($result); |
194 | 194 | $this->update($forum_id, 'digest', $digests); |
195 | 195 | |
196 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}"; |
|
196 | + $sql = ' SELECT COUNT(*)'.' FROM '.$this->db->prefix('newbb_posts')." WHERE approved=1 AND forum_id = {$forum_id}"; |
|
197 | 197 | $result = $this->db->query($sql); |
198 | 198 | list($posts) = $this->db->fetchRow($result); |
199 | 199 | $this->update($forum_id, 'post', $posts); |
200 | 200 | |
201 | 201 | foreach ($time_start as $period => $format) { |
202 | - $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(topic_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
202 | + $sql = ' SELECT COUNT(*), SUM(topic_views)'.' FROM '.$this->db->prefix('newbb_topics')." WHERE approved=1 AND forum_id = {$forum_id}"." AND FROM_UNIXTIME(topic_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
203 | 203 | $result = $this->db->query($sql); |
204 | 204 | list($topics, $views) = $this->db->fetchRow($result); |
205 | 205 | $views = empty($views) ? 0 : $views; // null check |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | @$counts['topic'][$period] += $topics; |
223 | 223 | @$counts['view'][$period] += $views; |
224 | 224 | |
225 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(digest_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
225 | + $sql = ' SELECT COUNT(*)'.' FROM '.$this->db->prefix('newbb_topics')." WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}"." AND FROM_UNIXTIME(digest_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
226 | 226 | $result = $this->db->query($sql); |
227 | 227 | list($digests) = $this->db->fetchRow($result); |
228 | 228 | $this->db->queryF(" INSERT INTO {$this->table}" |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | . "', NOW(), '{$format}')"); |
236 | 236 | @$counts['digest'][$period] += $digests; |
237 | 237 | |
238 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(post_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
238 | + $sql = ' SELECT COUNT(*)'.' FROM '.$this->db->prefix('newbb_posts')." WHERE approved=1 AND forum_id = {$forum_id}"." AND FROM_UNIXTIME(post_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
239 | 239 | $result = $this->db->query($sql); |
240 | 240 | list($posts) = $this->db->fetchRow($result); |
241 | 241 | $this->db->queryF(" INSERT INTO {$this->table}" |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . array_search('total', $this->param['period'], true)); |
|
253 | + $this->db->queryF(" DELETE FROM {$this->table}"." WHERE stats_id = '0' AND stats_period <> ".array_search('total', $this->param['period'], true)); |
|
254 | 254 | foreach ($time_start as $period => $format) { |
255 | 255 | foreach (array_keys($counts) as $type) { |
256 | 256 | $this->db->queryF(" INSERT INTO {$this->table}" |
@@ -30,238 +30,238 @@ |
||
30 | 30 | */ |
31 | 31 | class StatsHandler |
32 | 32 | { |
33 | - public $db; |
|
34 | - public $table; |
|
35 | - public $param = [ |
|
36 | - 'type' => ['topic', 'post', 'digest', 'view'], |
|
37 | - 'period' => ['total', 'day', 'week', 'month'] |
|
38 | - ]; |
|
33 | + public $db; |
|
34 | + public $table; |
|
35 | + public $param = [ |
|
36 | + 'type' => ['topic', 'post', 'digest', 'view'], |
|
37 | + 'period' => ['total', 'day', 'week', 'month'] |
|
38 | + ]; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param null|\XoopsDatabase $db |
|
42 | - */ |
|
43 | - public function __construct(\XoopsDatabase $db = null) |
|
44 | - { |
|
45 | - //$this->db = $db; |
|
46 | - //if (!$db || !($db instanceof XoopsDatabase)) { |
|
47 | - $this->db = $GLOBALS['xoopsDB']; |
|
48 | - //} |
|
49 | - $this->table = $this->db->prefix('newbb_stats'); |
|
50 | - } |
|
40 | + /** |
|
41 | + * @param null|\XoopsDatabase $db |
|
42 | + */ |
|
43 | + public function __construct(\XoopsDatabase $db = null) |
|
44 | + { |
|
45 | + //$this->db = $db; |
|
46 | + //if (!$db || !($db instanceof XoopsDatabase)) { |
|
47 | + $this->db = $GLOBALS['xoopsDB']; |
|
48 | + //} |
|
49 | + $this->table = $this->db->prefix('newbb_stats'); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param null|\XoopsDatabase $db |
|
54 | - * @return StatsHandler |
|
55 | - */ |
|
56 | - public static function getInstance(\XoopsDatabase $db = null) |
|
57 | - { |
|
58 | - static $instance; |
|
59 | - if (null === $instance) { |
|
60 | - $instance = new static($db); |
|
61 | - } |
|
52 | + /** |
|
53 | + * @param null|\XoopsDatabase $db |
|
54 | + * @return StatsHandler |
|
55 | + */ |
|
56 | + public static function getInstance(\XoopsDatabase $db = null) |
|
57 | + { |
|
58 | + static $instance; |
|
59 | + if (null === $instance) { |
|
60 | + $instance = new static($db); |
|
61 | + } |
|
62 | 62 | |
63 | - return $instance; |
|
64 | - } |
|
63 | + return $instance; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param $id |
|
68 | - * @param $type |
|
69 | - * @param int $increment |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function update($id, $type, $increment = 1) |
|
73 | - { |
|
74 | - $id = (int)$id; |
|
75 | - $increment = (int)$increment; |
|
66 | + /** |
|
67 | + * @param $id |
|
68 | + * @param $type |
|
69 | + * @param int $increment |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function update($id, $type, $increment = 1) |
|
73 | + { |
|
74 | + $id = (int)$id; |
|
75 | + $increment = (int)$increment; |
|
76 | 76 | |
77 | - if (empty($increment) || false === ($type = array_search($type, $this->param['type']))) { |
|
78 | - return false; |
|
79 | - } |
|
77 | + if (empty($increment) || false === ($type = array_search($type, $this->param['type']))) { |
|
78 | + return false; |
|
79 | + } |
|
80 | 80 | |
81 | - $sql = " UPDATE {$this->table}" |
|
82 | - . ' SET stats_value = CASE ' |
|
83 | - . " WHEN time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) THEN stats_value + '{$increment}' " |
|
84 | - . " ELSE '{$increment}' " |
|
85 | - . ' END, ' |
|
86 | - . ' time_update = NOW()' |
|
87 | - . ' WHERE ' |
|
88 | - . " (stats_id = '0' OR stats_id = '{$id}') " |
|
89 | - . " AND stats_type='{$type}' "; |
|
90 | - $result = $this->db->queryF($sql); |
|
91 | - $rows = $this->db->getAffectedRows(); |
|
92 | - if (0 == $rows) { |
|
93 | - $sql = " INSERT INTO {$this->table}" |
|
94 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
95 | - . ' VALUES ' |
|
96 | - . " ('0', '{$increment}', '{$type}', '" |
|
97 | - . array_search('total', $this->param['period'], true) |
|
98 | - . "', NOW(), ''), " |
|
99 | - . " ('0', '{$increment}', '{$type}', '" |
|
100 | - . array_search('day', $this->param['period'], true) |
|
101 | - . "', NOW(), '%Y%j'), " |
|
102 | - . " ('0', '{$increment}', '{$type}', '" |
|
103 | - . array_search('week', $this->param['period'], true) |
|
104 | - . "', NOW(), '%Y%u'), " |
|
105 | - . " ('0', '{$increment}', '{$type}', '" |
|
106 | - . array_search('month', $this->param['period'], true) |
|
107 | - . "', NOW(), '%Y%m')"; |
|
108 | - $result = $this->db->queryF($sql); |
|
109 | - } |
|
110 | - if ($rows < 2 * count($this->param['period']) && !empty($id)) { |
|
111 | - $sql = " INSERT INTO {$this->table}" |
|
112 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
113 | - . ' VALUES ' |
|
114 | - . " ('{$id}', '{$increment}', '{$type}', '" |
|
115 | - . array_search('total', $this->param['period'], true) |
|
116 | - . "', NOW(), ''), " |
|
117 | - . " ('{$id}', '{$increment}', '{$type}', '" |
|
118 | - . array_search('day', $this->param['period'], true) |
|
119 | - . "', NOW(), '%Y%j'), " |
|
120 | - . " ('{$id}', '{$increment}', '{$type}', '" |
|
121 | - . array_search('week', $this->param['period'], true) |
|
122 | - . "', NOW(), '%Y%u'), " |
|
123 | - . " ('{$id}', '{$increment}', '{$type}', '" |
|
124 | - . array_search('month', $this->param['period'], true) |
|
125 | - . "', NOW(), '%Y%m')"; |
|
126 | - $result = $this->db->queryF($sql); |
|
127 | - } |
|
128 | - } |
|
81 | + $sql = " UPDATE {$this->table}" |
|
82 | + . ' SET stats_value = CASE ' |
|
83 | + . " WHEN time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) THEN stats_value + '{$increment}' " |
|
84 | + . " ELSE '{$increment}' " |
|
85 | + . ' END, ' |
|
86 | + . ' time_update = NOW()' |
|
87 | + . ' WHERE ' |
|
88 | + . " (stats_id = '0' OR stats_id = '{$id}') " |
|
89 | + . " AND stats_type='{$type}' "; |
|
90 | + $result = $this->db->queryF($sql); |
|
91 | + $rows = $this->db->getAffectedRows(); |
|
92 | + if (0 == $rows) { |
|
93 | + $sql = " INSERT INTO {$this->table}" |
|
94 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
95 | + . ' VALUES ' |
|
96 | + . " ('0', '{$increment}', '{$type}', '" |
|
97 | + . array_search('total', $this->param['period'], true) |
|
98 | + . "', NOW(), ''), " |
|
99 | + . " ('0', '{$increment}', '{$type}', '" |
|
100 | + . array_search('day', $this->param['period'], true) |
|
101 | + . "', NOW(), '%Y%j'), " |
|
102 | + . " ('0', '{$increment}', '{$type}', '" |
|
103 | + . array_search('week', $this->param['period'], true) |
|
104 | + . "', NOW(), '%Y%u'), " |
|
105 | + . " ('0', '{$increment}', '{$type}', '" |
|
106 | + . array_search('month', $this->param['period'], true) |
|
107 | + . "', NOW(), '%Y%m')"; |
|
108 | + $result = $this->db->queryF($sql); |
|
109 | + } |
|
110 | + if ($rows < 2 * count($this->param['period']) && !empty($id)) { |
|
111 | + $sql = " INSERT INTO {$this->table}" |
|
112 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
113 | + . ' VALUES ' |
|
114 | + . " ('{$id}', '{$increment}', '{$type}', '" |
|
115 | + . array_search('total', $this->param['period'], true) |
|
116 | + . "', NOW(), ''), " |
|
117 | + . " ('{$id}', '{$increment}', '{$type}', '" |
|
118 | + . array_search('day', $this->param['period'], true) |
|
119 | + . "', NOW(), '%Y%j'), " |
|
120 | + . " ('{$id}', '{$increment}', '{$type}', '" |
|
121 | + . array_search('week', $this->param['period'], true) |
|
122 | + . "', NOW(), '%Y%u'), " |
|
123 | + . " ('{$id}', '{$increment}', '{$type}', '" |
|
124 | + . array_search('month', $this->param['period'], true) |
|
125 | + . "', NOW(), '%Y%m')"; |
|
126 | + $result = $this->db->queryF($sql); |
|
127 | + } |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Get stats of "Today" |
|
132 | - * |
|
133 | - * @param array $ids ID of forum: > 0, forum; 0 - global; empty - all |
|
134 | - * @param array $types type of stats items: 1 - topic; 2 - post; 3 - digest; 4 - click; empty - all |
|
135 | - * @param array $periods time period: 1 - all time; 2 - today; 3 - this week; 4 - this month; empty - all |
|
136 | - * @return array |
|
137 | - */ |
|
138 | - public function getStats(array $ids, array $types = [], array $periods = []) |
|
139 | - { |
|
140 | - $ret = []; |
|
130 | + /** |
|
131 | + * Get stats of "Today" |
|
132 | + * |
|
133 | + * @param array $ids ID of forum: > 0, forum; 0 - global; empty - all |
|
134 | + * @param array $types type of stats items: 1 - topic; 2 - post; 3 - digest; 4 - click; empty - all |
|
135 | + * @param array $periods time period: 1 - all time; 2 - today; 3 - this week; 4 - this month; empty - all |
|
136 | + * @return array |
|
137 | + */ |
|
138 | + public function getStats(array $ids, array $types = [], array $periods = []) |
|
139 | + { |
|
140 | + $ret = []; |
|
141 | 141 | |
142 | - $_types = []; |
|
143 | - foreach ($types as $type) { |
|
144 | - $_types[] = array_search($type, $this->param['type']); |
|
145 | - } |
|
146 | - $_periods = []; |
|
147 | - foreach ($periods as $period) { |
|
148 | - $_periods[] = array_search($period, $this->param['period']); |
|
149 | - } |
|
150 | - $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' |
|
151 | - . " FROM {$this->table} " |
|
152 | - . ' WHERE ' |
|
153 | - . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) " |
|
154 | - . ' ' |
|
155 | - . (empty($ids) ? '' : 'AND stats_id IN (' |
|
156 | - . implode(', ', array_map('intval', $ids)) |
|
157 | - . ')') |
|
158 | - . ' ' |
|
159 | - . (empty($_types) ? '' : 'AND stats_type IN (' . implode(', ', $_types) . ')') |
|
160 | - . ' ' |
|
161 | - . (empty($_periods) ? '' : 'AND stats_period IN (' . implode(', ', $_periods) . ')'); |
|
162 | - $result = $this->db->query($sql); |
|
142 | + $_types = []; |
|
143 | + foreach ($types as $type) { |
|
144 | + $_types[] = array_search($type, $this->param['type']); |
|
145 | + } |
|
146 | + $_periods = []; |
|
147 | + foreach ($periods as $period) { |
|
148 | + $_periods[] = array_search($period, $this->param['period']); |
|
149 | + } |
|
150 | + $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' |
|
151 | + . " FROM {$this->table} " |
|
152 | + . ' WHERE ' |
|
153 | + . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) " |
|
154 | + . ' ' |
|
155 | + . (empty($ids) ? '' : 'AND stats_id IN (' |
|
156 | + . implode(', ', array_map('intval', $ids)) |
|
157 | + . ')') |
|
158 | + . ' ' |
|
159 | + . (empty($_types) ? '' : 'AND stats_type IN (' . implode(', ', $_types) . ')') |
|
160 | + . ' ' |
|
161 | + . (empty($_periods) ? '' : 'AND stats_period IN (' . implode(', ', $_periods) . ')'); |
|
162 | + $result = $this->db->query($sql); |
|
163 | 163 | |
164 | - while (false !== ($row = $this->db->fetchArray($result))) { |
|
165 | - $ret[(string)$row['stats_id']][$this->param['type'][$row['stats_type']]][$this->param['period'][$row['stats_period']]] = $row['stats_value']; |
|
166 | - } |
|
164 | + while (false !== ($row = $this->db->fetchArray($result))) { |
|
165 | + $ret[(string)$row['stats_id']][$this->param['type'][$row['stats_type']]][$this->param['period'][$row['stats_period']]] = $row['stats_value']; |
|
166 | + } |
|
167 | 167 | |
168 | - return $ret; |
|
169 | - } |
|
168 | + return $ret; |
|
169 | + } |
|
170 | 170 | |
171 | - public function reset() |
|
172 | - { |
|
173 | - $this->db->queryF('TRUNCATE TABLE ' . $this->table); |
|
174 | - $now = time(); |
|
175 | - $time_start = [ |
|
176 | - 'day' => '%Y%j', |
|
177 | - 'week' => '%Y%u', |
|
178 | - 'month' => '%Y%m' |
|
179 | - ]; |
|
180 | - $counts = []; |
|
171 | + public function reset() |
|
172 | + { |
|
173 | + $this->db->queryF('TRUNCATE TABLE ' . $this->table); |
|
174 | + $now = time(); |
|
175 | + $time_start = [ |
|
176 | + 'day' => '%Y%j', |
|
177 | + 'week' => '%Y%u', |
|
178 | + 'month' => '%Y%m' |
|
179 | + ]; |
|
180 | + $counts = []; |
|
181 | 181 | |
182 | - $sql = ' SELECT forum_id' . ' FROM ' . $this->db->prefix('newbb_forums'); |
|
183 | - $ret = $this->db->query($sql); |
|
184 | - while (false !== (list($forum_id) = $this->db->fetchRow($ret))) { |
|
185 | - $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}"; |
|
186 | - $result = $this->db->query($sql); |
|
187 | - list($topics, $views) = $this->db->fetchRow($result); |
|
188 | - $this->update($forum_id, 'topic', $topics); |
|
189 | - $this->update($forum_id, 'view', $views); |
|
182 | + $sql = ' SELECT forum_id' . ' FROM ' . $this->db->prefix('newbb_forums'); |
|
183 | + $ret = $this->db->query($sql); |
|
184 | + while (false !== (list($forum_id) = $this->db->fetchRow($ret))) { |
|
185 | + $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}"; |
|
186 | + $result = $this->db->query($sql); |
|
187 | + list($topics, $views) = $this->db->fetchRow($result); |
|
188 | + $this->update($forum_id, 'topic', $topics); |
|
189 | + $this->update($forum_id, 'view', $views); |
|
190 | 190 | |
191 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}"; |
|
192 | - $result = $this->db->query($sql); |
|
193 | - list($digests) = $this->db->fetchRow($result); |
|
194 | - $this->update($forum_id, 'digest', $digests); |
|
191 | + $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}"; |
|
192 | + $result = $this->db->query($sql); |
|
193 | + list($digests) = $this->db->fetchRow($result); |
|
194 | + $this->update($forum_id, 'digest', $digests); |
|
195 | 195 | |
196 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}"; |
|
197 | - $result = $this->db->query($sql); |
|
198 | - list($posts) = $this->db->fetchRow($result); |
|
199 | - $this->update($forum_id, 'post', $posts); |
|
196 | + $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}"; |
|
197 | + $result = $this->db->query($sql); |
|
198 | + list($posts) = $this->db->fetchRow($result); |
|
199 | + $this->update($forum_id, 'post', $posts); |
|
200 | 200 | |
201 | - foreach ($time_start as $period => $format) { |
|
202 | - $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(topic_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
203 | - $result = $this->db->query($sql); |
|
204 | - list($topics, $views) = $this->db->fetchRow($result); |
|
205 | - $views = empty($views) ? 0 : $views; // null check |
|
206 | - $this->db->queryF(" INSERT INTO {$this->table}" |
|
207 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
208 | - . ' VALUES ' |
|
209 | - . " ('{$forum_id}', '{$topics}', '" |
|
210 | - . array_search('topic', $this->param['type'], true) |
|
211 | - . "', '" |
|
212 | - . array_search($period, $this->param['period']) |
|
213 | - . "', NOW(), '{$format}')"); |
|
214 | - $this->db->queryF(" INSERT INTO {$this->table}" |
|
215 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
216 | - . ' VALUES ' |
|
217 | - . " ('{$forum_id}', '{$views}', '" |
|
218 | - . array_search('view', $this->param['type'], true) |
|
219 | - . "', '" |
|
220 | - . array_search($period, $this->param['period']) |
|
221 | - . "', NOW(), '{$format}')"); |
|
222 | - @$counts['topic'][$period] += $topics; |
|
223 | - @$counts['view'][$period] += $views; |
|
201 | + foreach ($time_start as $period => $format) { |
|
202 | + $sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(topic_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
203 | + $result = $this->db->query($sql); |
|
204 | + list($topics, $views) = $this->db->fetchRow($result); |
|
205 | + $views = empty($views) ? 0 : $views; // null check |
|
206 | + $this->db->queryF(" INSERT INTO {$this->table}" |
|
207 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
208 | + . ' VALUES ' |
|
209 | + . " ('{$forum_id}', '{$topics}', '" |
|
210 | + . array_search('topic', $this->param['type'], true) |
|
211 | + . "', '" |
|
212 | + . array_search($period, $this->param['period']) |
|
213 | + . "', NOW(), '{$format}')"); |
|
214 | + $this->db->queryF(" INSERT INTO {$this->table}" |
|
215 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
216 | + . ' VALUES ' |
|
217 | + . " ('{$forum_id}', '{$views}', '" |
|
218 | + . array_search('view', $this->param['type'], true) |
|
219 | + . "', '" |
|
220 | + . array_search($period, $this->param['period']) |
|
221 | + . "', NOW(), '{$format}')"); |
|
222 | + @$counts['topic'][$period] += $topics; |
|
223 | + @$counts['view'][$period] += $views; |
|
224 | 224 | |
225 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(digest_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
226 | - $result = $this->db->query($sql); |
|
227 | - list($digests) = $this->db->fetchRow($result); |
|
228 | - $this->db->queryF(" INSERT INTO {$this->table}" |
|
229 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
230 | - . ' VALUES ' |
|
231 | - . " ('{$forum_id}', '{$digests}', '" |
|
232 | - . array_search('digest', $this->param['type'], true) |
|
233 | - . "', '" |
|
234 | - . array_search($period, $this->param['period']) |
|
235 | - . "', NOW(), '{$format}')"); |
|
236 | - @$counts['digest'][$period] += $digests; |
|
225 | + $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(digest_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
226 | + $result = $this->db->query($sql); |
|
227 | + list($digests) = $this->db->fetchRow($result); |
|
228 | + $this->db->queryF(" INSERT INTO {$this->table}" |
|
229 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
230 | + . ' VALUES ' |
|
231 | + . " ('{$forum_id}', '{$digests}', '" |
|
232 | + . array_search('digest', $this->param['type'], true) |
|
233 | + . "', '" |
|
234 | + . array_search($period, $this->param['period']) |
|
235 | + . "', NOW(), '{$format}')"); |
|
236 | + @$counts['digest'][$period] += $digests; |
|
237 | 237 | |
238 | - $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(post_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
239 | - $result = $this->db->query($sql); |
|
240 | - list($posts) = $this->db->fetchRow($result); |
|
241 | - $this->db->queryF(" INSERT INTO {$this->table}" |
|
242 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
243 | - . ' VALUES ' |
|
244 | - . " ('{$forum_id}', '{$posts}', '" |
|
245 | - . array_search('post', $this->param['type']) |
|
246 | - . "', '" |
|
247 | - . array_search($period, $this->param['period'], true) |
|
248 | - . "', NOW(), '{$format}')"); |
|
249 | - @$counts['post'][$period] += $posts; |
|
250 | - } |
|
251 | - } |
|
238 | + $sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(post_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')"; |
|
239 | + $result = $this->db->query($sql); |
|
240 | + list($posts) = $this->db->fetchRow($result); |
|
241 | + $this->db->queryF(" INSERT INTO {$this->table}" |
|
242 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
243 | + . ' VALUES ' |
|
244 | + . " ('{$forum_id}', '{$posts}', '" |
|
245 | + . array_search('post', $this->param['type']) |
|
246 | + . "', '" |
|
247 | + . array_search($period, $this->param['period'], true) |
|
248 | + . "', NOW(), '{$format}')"); |
|
249 | + @$counts['post'][$period] += $posts; |
|
250 | + } |
|
251 | + } |
|
252 | 252 | |
253 | - $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . array_search('total', $this->param['period'], true)); |
|
254 | - foreach ($time_start as $period => $format) { |
|
255 | - foreach (array_keys($counts) as $type) { |
|
256 | - $this->db->queryF(" INSERT INTO {$this->table}" |
|
257 | - . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
258 | - . ' VALUES ' |
|
259 | - . " ('0', '{$counts[$type][$period]}', '" |
|
260 | - . array_search($type, $this->param['type'], true) |
|
261 | - . "', '" |
|
262 | - . array_search($period, $this->param['period'], true) |
|
263 | - . "', NOW(), '{$format}')"); |
|
264 | - } |
|
265 | - } |
|
266 | - } |
|
253 | + $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . array_search('total', $this->param['period'], true)); |
|
254 | + foreach ($time_start as $period => $format) { |
|
255 | + foreach (array_keys($counts) as $type) { |
|
256 | + $this->db->queryF(" INSERT INTO {$this->table}" |
|
257 | + . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' |
|
258 | + . ' VALUES ' |
|
259 | + . " ('0', '{$counts[$type][$period]}', '" |
|
260 | + . array_search($type, $this->param['type'], true) |
|
261 | + . "', '" |
|
262 | + . array_search($period, $this->param['period'], true) |
|
263 | + . "', NOW(), '{$format}')"); |
|
264 | + } |
|
265 | + } |
|
266 | + } |
|
267 | 267 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.00 |
9 | 9 | * @package module::newbb |
10 | 10 | */ |
11 | -require_once __DIR__ . '/header.php'; |
|
11 | +require_once __DIR__.'/header.php'; |
|
12 | 12 | |
13 | 13 | if (!is_object($GLOBALS['xoopsUser']) || !$GLOBALS['xoopsUser']->isAdmin()) { |
14 | 14 | exit(_NOPERM); |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | exit('No need for update'); |
23 | 23 | } |
24 | 24 | |
25 | -$GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
26 | -$GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
25 | +$GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
26 | +$GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
27 | 27 | |
28 | 28 | if (!$GLOBALS['xoopsDB']->queryF(' |
29 | - CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp') . " ( |
|
29 | + CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')." ( |
|
30 | 30 | `type_id` SMALLINT(4) UNSIGNED NOT NULL AUTO_INCREMENT, |
31 | 31 | `type_name` VARCHAR(64) NOT NULL DEFAULT '', |
32 | 32 | `type_color` VARCHAR(10) NOT NULL DEFAULT '', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | if (!$GLOBALS['xoopsDB']->queryF(' |
42 | - CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp') . " ( |
|
42 | + CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')." ( |
|
43 | 43 | `tf_id` MEDIUMINT(4) UNSIGNED NOT NULL AUTO_INCREMENT, |
44 | 44 | `type_id` SMALLINT(4) UNSIGNED NOT NULL DEFAULT '0', |
45 | 45 | `forum_id` SMALLINT(4) UNSIGNED NOT NULL DEFAULT '0', |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | KEY `type_order` (`type_order`) |
51 | 51 | ) ENGINE=MyISAM; |
52 | 52 | ")) { |
53 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
53 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
54 | 54 | exit('Can not create tmp table for `bb_type_forum_tmp`'); |
55 | 55 | } |
56 | 56 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | foreach ($subjectpres as $subjectpre) { |
62 | 62 | if (preg_match("/<[^#]*color=[\"'](#[^'\"\s]*)[^>]>[\[]?([^<\]]*)[\]]?/is", $subjectpre, $matches)) { |
63 | 63 | if (!$GLOBALS['xoopsDB']->queryF(' |
64 | - INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp') . ' |
|
64 | + INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp').' |
|
65 | 65 | (`type_name`, `type_color`) |
66 | 66 | VALUES |
67 | - (' . $GLOBALS['xoopsDB']->quoteString($matches[2]) . ', ' . $GLOBALS['xoopsDB']->quoteString($matches[1]) . ') |
|
67 | + (' . $GLOBALS['xoopsDB']->quoteString($matches[2]).', '.$GLOBALS['xoopsDB']->quoteString($matches[1]).') |
|
68 | 68 | ')) { |
69 | 69 | xoops_error("Can not add type of `{$matches[2]}`"); |
70 | 70 | continue; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | if (0 === count($types)) { |
76 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
77 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
76 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
77 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
78 | 78 | exit('No type item created'); |
79 | 79 | } |
80 | 80 | |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $type_query[] = "({$key}, {$forum_id}, {$order})"; |
88 | 88 | } |
89 | 89 | |
90 | - $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . implode(', ', $type_query); |
|
90 | + $sql = 'INSERT INTO '.$GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp').' (type_id, forum_id, type_order) '.' VALUES '.implode(', ', $type_query); |
|
91 | 91 | if (false === ($result = $GLOBALS['xoopsDB']->queryF($sql))) { |
92 | 92 | xoops_error($GLOBALS['xoopsDB']->error()); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | } else { |
96 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
97 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
96 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
97 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE '.$GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
98 | 98 | exit('No type item to update'); |
99 | 99 | } |
100 | 100 |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | require_once __DIR__ . '/header.php'; |
12 | 12 | |
13 | 13 | if (!is_object($GLOBALS['xoopsUser']) || !$GLOBALS['xoopsUser']->isAdmin()) { |
14 | - exit(_NOPERM); |
|
14 | + exit(_NOPERM); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | if ($xoopsModule->getVar('version') >= 401) { |
18 | - exit('Version not valid'); |
|
18 | + exit('Version not valid'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if (empty($GLOBALS['xoopsModuleConfig']['subject_prefix'])) { |
22 | - exit('No need for update'); |
|
22 | + exit('No need for update'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | PRIMARY KEY (`type_id`) |
36 | 36 | ) ENGINE=MyISAM; |
37 | 37 | ")) { |
38 | - exit('Can not create tmp table for `bb_type_tmp`'); |
|
38 | + exit('Can not create tmp table for `bb_type_tmp`'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | if (!$GLOBALS['xoopsDB']->queryF(' |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | KEY `type_order` (`type_order`) |
51 | 51 | ) ENGINE=MyISAM; |
52 | 52 | ")) { |
53 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
54 | - exit('Can not create tmp table for `bb_type_forum_tmp`'); |
|
53 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
54 | + exit('Can not create tmp table for `bb_type_forum_tmp`'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | //$typeHandler = Newbb\Helper::getInstance()->getHandler('Type'); |
@@ -59,43 +59,43 @@ discard block |
||
59 | 59 | $types = []; |
60 | 60 | $order = 1; |
61 | 61 | foreach ($subjectpres as $subjectpre) { |
62 | - if (preg_match("/<[^#]*color=[\"'](#[^'\"\s]*)[^>]>[\[]?([^<\]]*)[\]]?/is", $subjectpre, $matches)) { |
|
63 | - if (!$GLOBALS['xoopsDB']->queryF(' |
|
62 | + if (preg_match("/<[^#]*color=[\"'](#[^'\"\s]*)[^>]>[\[]?([^<\]]*)[\]]?/is", $subjectpre, $matches)) { |
|
63 | + if (!$GLOBALS['xoopsDB']->queryF(' |
|
64 | 64 | INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp') . ' |
65 | 65 | (`type_name`, `type_color`) |
66 | 66 | VALUES |
67 | 67 | (' . $GLOBALS['xoopsDB']->quoteString($matches[2]) . ', ' . $GLOBALS['xoopsDB']->quoteString($matches[1]) . ') |
68 | 68 | ')) { |
69 | - xoops_error("Can not add type of `{$matches[2]}`"); |
|
70 | - continue; |
|
71 | - } |
|
72 | - $types[$GLOBALS['xoopsDB']->getInsertId()] = $order++; |
|
73 | - } |
|
69 | + xoops_error("Can not add type of `{$matches[2]}`"); |
|
70 | + continue; |
|
71 | + } |
|
72 | + $types[$GLOBALS['xoopsDB']->getInsertId()] = $order++; |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | if (0 === count($types)) { |
76 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
77 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
78 | - exit('No type item created'); |
|
76 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
77 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
78 | + exit('No type item created'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | ///** @var Newbb\ForumHandler $forumHandler */ |
82 | 82 | //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
83 | 83 | if ($forums_type = $forumHandler->getIds(new \Criteria('allow_subject_prefix', 1))) { |
84 | - foreach ($forums_type as $forum_id) { |
|
85 | - $type_query = []; |
|
86 | - foreach ($types as $key => $order) { |
|
87 | - $type_query[] = "({$key}, {$forum_id}, {$order})"; |
|
88 | - } |
|
84 | + foreach ($forums_type as $forum_id) { |
|
85 | + $type_query = []; |
|
86 | + foreach ($types as $key => $order) { |
|
87 | + $type_query[] = "({$key}, {$forum_id}, {$order})"; |
|
88 | + } |
|
89 | 89 | |
90 | - $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . implode(', ', $type_query); |
|
91 | - if (false === ($result = $GLOBALS['xoopsDB']->queryF($sql))) { |
|
92 | - xoops_error($GLOBALS['xoopsDB']->error()); |
|
93 | - } |
|
94 | - } |
|
90 | + $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . implode(', ', $type_query); |
|
91 | + if (false === ($result = $GLOBALS['xoopsDB']->queryF($sql))) { |
|
92 | + xoops_error($GLOBALS['xoopsDB']->error()); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | } else { |
96 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
97 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
98 | - exit('No type item to update'); |
|
96 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_tmp')); |
|
97 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('newbb_type_forum_tmp')); |
|
98 | + exit('No type item to update'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | die('update succeeded'); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | */ |
42 | 42 | |
43 | -require_once __DIR__ . '/header.php'; |
|
43 | +require_once __DIR__.'/header.php'; |
|
44 | 44 | |
45 | 45 | error_reporting(0); |
46 | 46 | $xoopsLogger->activated = false; |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $topic_id = $post->getVar('topic_id'); |
66 | 66 | $post_data = $postHandler->getPostForPrint($post); |
67 | 67 | $isPost = 1; |
68 | - $post_data['url'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id; |
|
68 | + $post_data['url'] = XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$post_id; |
|
69 | 69 | if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
70 | - $post_data['url'] = seo_urls('<a href="' . $post_data['url'] . '"></a>'); |
|
70 | + $post_data['url'] = seo_urls('<a href="'.$post_data['url'].'"></a>'); |
|
71 | 71 | $post_data['url'] = str_replace('<a href="', '', $post_data['url']); |
72 | 72 | $post_data['url'] = str_replace('"></a>', '', $post_data['url']); |
73 | 73 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
114 | 114 | <div style='width: 750px; border: 1px solid #000; padding: 20px;'> |
115 | 115 | <div style='text-align: center; display: block; margin: 0 0 6px 0;'> |
116 | - <img src='" . XOOPS_URL . "/modules/newbb/assets/images/xoopsbb_slogo.png' border='0' alt='' /> |
|
116 | + <img src='" . XOOPS_URL."/modules/newbb/assets/images/xoopsbb_slogo.png' border='0' alt='' /> |
|
117 | 117 | <br><br> "; |
118 | 118 | |
119 | 119 | $postsArray = $topicHandler->getAllPosts($topicObject); |
@@ -122,25 +122,25 @@ discard block |
||
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | $post_data = $postHandler->getPostForPrint($post); |
125 | - echo "<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2> |
|
126 | - <div align='center'>" . _POSTEDBY . ' ' . $post_data['author'] . ' ' . _ON . ' ' . formatTimestamp($post_data['date']) . "</div> |
|
125 | + echo "<h2 style='margin: 0;'>".$post_data['subject']."</h2> |
|
126 | + <div align='center'>" . _POSTEDBY.' '.$post_data['author'].' '._ON.' '.formatTimestamp($post_data['date'])."</div> |
|
127 | 127 | <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div> |
128 | - <div>" . $post_data['text'] . "</div> |
|
128 | + <div>" . $post_data['text']."</div> |
|
129 | 129 | <div style='padding-top: 12px; border-top: 2px solid #ccc;'></div><br>"; |
130 | 130 | } |
131 | - echo '<p>' . _MD_NEWBB_COMEFROM . ' ' . XOOPS_URL . '/newbb/viewtopic.php?forum=' . $forum_id . '&topic_id=' . $topic_id . '</p>'; |
|
131 | + echo '<p>'._MD_NEWBB_COMEFROM.' '.XOOPS_URL.'/newbb/viewtopic.php?forum='.$forum_id.'&topic_id='.$topic_id.'</p>'; |
|
132 | 132 | echo '</div></div>'; |
133 | 133 | echo '</body></html>'; |
134 | 134 | } else { |
135 | 135 | echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
136 | 136 | <div style='width: 750px; border: 1px solid #000; padding: 20px;'> |
137 | 137 | <div style='text-align: center; display: block; margin: 0 0 6px 0;'> |
138 | - <h2 style='margin: 0;'>" . $post_data['subject'] . "</h2></div> |
|
139 | - <div align='center'>" . _POSTEDBY . ' ' . $post_data['author'] . ' ' . _ON . ' ' . formatTimestamp($post_data['date']) . "</div> |
|
138 | + <h2 style='margin: 0;'>" . $post_data['subject']."</h2></div> |
|
139 | + <div align='center'>" . _POSTEDBY.' '.$post_data['author'].' '._ON.' '.formatTimestamp($post_data['date'])."</div> |
|
140 | 140 | <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div> |
141 | - <div>" . $post_data['text'] . "</div> |
|
141 | + <div>" . $post_data['text']."</div> |
|
142 | 142 | <div style='padding-top: 12px; border-top: 2px solid #ccc;'></div> |
143 | - <p>" . _MD_NEWBB_COMEFROM . ' ' . $post_data['url'] . '</p> |
|
143 | + <p>" . _MD_NEWBB_COMEFROM.' '.$post_data['url'].'</p> |
|
144 | 144 | </div> |
145 | 145 | <br><br></body></html>'; |
146 | 146 | } |
@@ -46,93 +46,93 @@ |
||
46 | 46 | $xoopsLogger->activated = false; |
47 | 47 | |
48 | 48 | if (!Request::getString('post_data', '', 'POST')) { |
49 | - $forum = Request::getInt('forum', 0, 'GET'); |
|
50 | - $topic_id = Request::getInt('topic_id', 0, 'GET'); |
|
51 | - $post_id = Request::getInt('post_id', 0, 'GET'); |
|
49 | + $forum = Request::getInt('forum', 0, 'GET'); |
|
50 | + $topic_id = Request::getInt('topic_id', 0, 'GET'); |
|
51 | + $post_id = Request::getInt('post_id', 0, 'GET'); |
|
52 | 52 | |
53 | - if (0 === $post_id && 0 === $topic_id) { |
|
54 | - exit(_MD_NEWBB_ERRORTOPIC); |
|
55 | - } |
|
53 | + if (0 === $post_id && 0 === $topic_id) { |
|
54 | + exit(_MD_NEWBB_ERRORTOPIC); |
|
55 | + } |
|
56 | 56 | |
57 | - if (0 !== $post_id) { |
|
58 | - // /** @var Newbb\PostHandler $postHandler */ |
|
59 | - // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
60 | - /** @var Newbb\Post $post */ |
|
61 | - $post = $postHandler->get($post_id); |
|
62 | - if (!$approved = $post->getVar('approved')) { |
|
63 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
64 | - } |
|
65 | - $topic_id = $post->getVar('topic_id'); |
|
66 | - $post_data = $postHandler->getPostForPrint($post); |
|
67 | - $isPost = 1; |
|
68 | - $post_data['url'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id; |
|
69 | - if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
70 | - $post_data['url'] = seo_urls('<a href="' . $post_data['url'] . '"></a>'); |
|
71 | - $post_data['url'] = str_replace('<a href="', '', $post_data['url']); |
|
72 | - $post_data['url'] = str_replace('"></a>', '', $post_data['url']); |
|
73 | - } |
|
74 | - } |
|
57 | + if (0 !== $post_id) { |
|
58 | + // /** @var Newbb\PostHandler $postHandler */ |
|
59 | + // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
60 | + /** @var Newbb\Post $post */ |
|
61 | + $post = $postHandler->get($post_id); |
|
62 | + if (!$approved = $post->getVar('approved')) { |
|
63 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
64 | + } |
|
65 | + $topic_id = $post->getVar('topic_id'); |
|
66 | + $post_data = $postHandler->getPostForPrint($post); |
|
67 | + $isPost = 1; |
|
68 | + $post_data['url'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id; |
|
69 | + if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { |
|
70 | + $post_data['url'] = seo_urls('<a href="' . $post_data['url'] . '"></a>'); |
|
71 | + $post_data['url'] = str_replace('<a href="', '', $post_data['url']); |
|
72 | + $post_data['url'] = str_replace('"></a>', '', $post_data['url']); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - // /** @var Newbb\TopicHandler $topicHandler */ |
|
77 | - // $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
78 | - $topicObject = $topicHandler->get($topic_id); |
|
79 | - $topic_id = $topicObject->getVar('topic_id'); |
|
80 | - $forum = $topicObject->getVar('forum_id'); |
|
81 | - if (!$approved = $topicObject->getVar('approved')) { |
|
82 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
83 | - } |
|
76 | + // /** @var Newbb\TopicHandler $topicHandler */ |
|
77 | + // $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
78 | + $topicObject = $topicHandler->get($topic_id); |
|
79 | + $topic_id = $topicObject->getVar('topic_id'); |
|
80 | + $forum = $topicObject->getVar('forum_id'); |
|
81 | + if (!$approved = $topicObject->getVar('approved')) { |
|
82 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
83 | + } |
|
84 | 84 | |
85 | - $isAdmin = newbbIsAdmin($forumObject); |
|
86 | - if (!$isAdmin && $topicObject->getVar('approved') < 0) { |
|
87 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
88 | - } |
|
85 | + $isAdmin = newbbIsAdmin($forumObject); |
|
86 | + if (!$isAdmin && $topicObject->getVar('approved') < 0) { |
|
87 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
88 | + } |
|
89 | 89 | |
90 | - // /** @var Newbb\ForumHandler $forumHandler */ |
|
91 | - // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
92 | - $forum = $topicObject->getVar('forum_id'); |
|
93 | - $forumObject = $forumHandler->get($forum); |
|
94 | - if (!$forumHandler->getPermission($forumObject)) { |
|
95 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
96 | - } |
|
90 | + // /** @var Newbb\ForumHandler $forumHandler */ |
|
91 | + // $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
92 | + $forum = $topicObject->getVar('forum_id'); |
|
93 | + $forumObject = $forumHandler->get($forum); |
|
94 | + if (!$forumHandler->getPermission($forumObject)) { |
|
95 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
96 | + } |
|
97 | 97 | |
98 | - if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
|
99 | - exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
100 | - } |
|
101 | - // irmtfan add print permission |
|
102 | - if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'print')) { |
|
103 | - exit(_MD_NEWBB_NORIGHTTOPRINT); |
|
104 | - } |
|
98 | + if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) { |
|
99 | + exit(_MD_NEWBB_NORIGHTTOVIEW); |
|
100 | + } |
|
101 | + // irmtfan add print permission |
|
102 | + if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'print')) { |
|
103 | + exit(_MD_NEWBB_NORIGHTTOPRINT); |
|
104 | + } |
|
105 | 105 | } else { |
106 | - $post_data = unserialize(base64_decode(Request::getString('post_data', '', 'POST'))); |
|
107 | - $isPost = 1; |
|
106 | + $post_data = unserialize(base64_decode(Request::getString('post_data', '', 'POST'))); |
|
107 | + $isPost = 1; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | xoops_header(false); |
111 | 111 | |
112 | 112 | if (empty($isPost)) { |
113 | - echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
113 | + echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
114 | 114 | <div style='width: 750px; border: 1px solid #000; padding: 20px;'> |
115 | 115 | <div style='text-align: center; display: block; margin: 0 0 6px 0;'> |
116 | 116 | <img src='" . XOOPS_URL . "/modules/newbb/assets/images/xoopsbb_slogo.png' border='0' alt='' /> |
117 | 117 | <br><br> "; |
118 | 118 | |
119 | - $postsArray = $topicHandler->getAllPosts($topicObject); |
|
120 | - foreach ($postsArray as $post) { |
|
121 | - if (!$post->getVar('approved')) { |
|
122 | - continue; |
|
123 | - } |
|
124 | - $post_data = $postHandler->getPostForPrint($post); |
|
125 | - echo "<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2> |
|
119 | + $postsArray = $topicHandler->getAllPosts($topicObject); |
|
120 | + foreach ($postsArray as $post) { |
|
121 | + if (!$post->getVar('approved')) { |
|
122 | + continue; |
|
123 | + } |
|
124 | + $post_data = $postHandler->getPostForPrint($post); |
|
125 | + echo "<h2 style='margin: 0;'>" . $post_data['subject'] . "</h2> |
|
126 | 126 | <div align='center'>" . _POSTEDBY . ' ' . $post_data['author'] . ' ' . _ON . ' ' . formatTimestamp($post_data['date']) . "</div> |
127 | 127 | <div style='text-align: center; display: block; padding-bottom: 12px; margin: 0 0 6px 0; border-bottom: 2px solid #ccc;'></div> |
128 | 128 | <div>" . $post_data['text'] . "</div> |
129 | 129 | <div style='padding-top: 12px; border-top: 2px solid #ccc;'></div><br>"; |
130 | - } |
|
131 | - echo '<p>' . _MD_NEWBB_COMEFROM . ' ' . XOOPS_URL . '/newbb/viewtopic.php?forum=' . $forum_id . '&topic_id=' . $topic_id . '</p>'; |
|
132 | - echo '</div></div>'; |
|
133 | - echo '</body></html>'; |
|
130 | + } |
|
131 | + echo '<p>' . _MD_NEWBB_COMEFROM . ' ' . XOOPS_URL . '/newbb/viewtopic.php?forum=' . $forum_id . '&topic_id=' . $topic_id . '</p>'; |
|
132 | + echo '</div></div>'; |
|
133 | + echo '</body></html>'; |
|
134 | 134 | } else { |
135 | - echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
135 | + echo "</head><body style='background-color:#ffffff; color:#000000;' onload='window.print()'> |
|
136 | 136 | <div style='width: 750px; border: 1px solid #000; padding: 20px;'> |
137 | 137 | <div style='text-align: center; display: block; margin: 0 0 6px 0;'> |
138 | 138 | <h2 style='margin: 0;'>" . $post_data['subject'] . "</h2></div> |