@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use XoopsModules\Newbb; |
| 5 | 5 | |
| 6 | -define('REAL_MODULE_NAME', 'modules/newbb'); //this is the Real Module directory |
|
| 7 | -define('SEO_MODULE_NAME', 'modules/newbb'); //this is SEO Name for rewrite Hack |
|
| 6 | +define('REAL_MODULE_NAME', 'modules/newbb'); //this is the Real Module directory |
|
| 7 | +define('SEO_MODULE_NAME', 'modules/newbb'); //this is SEO Name for rewrite Hack |
|
| 8 | 8 | |
| 9 | 9 | //ob_start('seo_urls'); |
| 10 | 10 | |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | $search = [ |
| 21 | 21 | |
| 22 | 22 | // Search URLs of modules' directry. |
| 23 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 24 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 25 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 26 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 27 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 28 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 29 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
| 23 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 24 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 25 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 26 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 27 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 28 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 29 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
| 30 | 30 | ]; |
| 31 | 31 | |
| 32 | 32 | $s = preg_replace_callback($search, 'replace_links', $s); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if (!empty($matches[6])) { |
| 48 | 48 | // replacing cat=x |
| 49 | 49 | if (preg_match('/cat=(\d+)/', $matches[6], $mvars)) { |
| 50 | - $add_to_url = 'c-' . $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
| 50 | + $add_to_url = 'c-'.$mvars[1].'/'.forum_seo_cat($mvars[1]).''; |
|
| 51 | 51 | $req_string = preg_replace('/cat=\d+/', '', $matches[6]); |
| 52 | 52 | } else { |
| 53 | 53 | return $matches['0']; |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | if (!empty($matches[6])) { |
| 61 | 61 | // replacing status=x |
| 62 | 62 | if (preg_match('/status=([a-z]+)/', $matches[6], $mvars)) { |
| 63 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
| 63 | + $add_to_url = 'viewpost.php'.$matches[6]; |
|
| 64 | 64 | $req_string = preg_replace('/status=([a-z])+/', '', $matches[6]); |
| 65 | 65 | } else { |
| 66 | 66 | return $matches['0']; |
| 67 | 67 | } |
| 68 | 68 | } else { |
| 69 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
| 69 | + $add_to_url = 'viewpost.php'.$matches[6]; |
|
| 70 | 70 | } |
| 71 | 71 | break; |
| 72 | 72 | case 'rss.php': |
@@ -77,17 +77,17 @@ discard block |
||
| 77 | 77 | if (preg_match('/c=(\d+)/', $matches[6], $mvars)) { |
| 78 | 78 | $add_to_url = 'rc-'; |
| 79 | 79 | if ($mvars[1] > 0) { |
| 80 | - $add_to_url .= $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
| 80 | + $add_to_url .= $mvars[1].'/'.forum_seo_cat($mvars[1]).''; |
|
| 81 | 81 | } else { |
| 82 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
| 82 | + $add_to_url .= $mvars[1].'/rss.html'; |
|
| 83 | 83 | } |
| 84 | 84 | $req_string = preg_replace('/c=\d+/', '', $matches[6]); |
| 85 | 85 | } elseif (preg_match('/f=(\d+)/', $matches[6], $mvars)) { |
| 86 | 86 | $add_to_url = 'rf-'; |
| 87 | 87 | if ($mvars[1] > 0) { |
| 88 | - $add_to_url .= $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
| 88 | + $add_to_url .= $mvars[1].'/'.forum_seo_forum($mvars[1]).''; |
|
| 89 | 89 | } else { |
| 90 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
| 90 | + $add_to_url .= $mvars[1].'/rss.html'; |
|
| 91 | 91 | } |
| 92 | 92 | $req_string = preg_replace('/f=\d+/', '', $matches[6]); |
| 93 | 93 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | if (!empty($matches[6])) { |
| 103 | 103 | // replacing forum=x |
| 104 | 104 | if (preg_match('/forum=(\d+)/', $matches[6], $mvars)) { |
| 105 | - $add_to_url = 'f-' . $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
| 105 | + $add_to_url = 'f-'.$mvars[1].'/'.forum_seo_forum($mvars[1]).''; |
|
| 106 | 106 | $req_string = preg_replace('/forum=\d+/', '', $matches[6]); |
| 107 | 107 | } else { |
| 108 | 108 | return $matches['0']; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | if (!empty($matches[6])) { |
| 116 | 116 | // replacing topic_id=x |
| 117 | 117 | if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
| 118 | - $add_to_url = 't-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 118 | + $add_to_url = 't-'.$mvars[1].'/'.forum_seo_topic($mvars[1]).''; |
|
| 119 | 119 | $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
| 120 | 120 | } //replacing post_id=x |
| 121 | 121 | elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
| 122 | - $add_to_url = 'p-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 122 | + $add_to_url = 'p-'.$mvars[1].'/'.forum_seo_post($mvars[1]).''; |
|
| 123 | 123 | $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
| 124 | 124 | } else { |
| 125 | 125 | return $matches['0']; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | if (!empty($matches[6])) { |
| 133 | 133 | // replacing topic_id=x |
| 134 | 134 | if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
| 135 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 135 | + $add_to_url = 'pr-'.$mvars[1].'/'.forum_seo_topic($mvars[1]).''; |
|
| 136 | 136 | $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
| 137 | 137 | } //replacing post_id=x |
| 138 | 138 | elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
| 139 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 139 | + $add_to_url = 'pr-'.$mvars[1].'/'.forum_seo_post($mvars[1]).''; |
|
| 140 | 140 | $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
| 141 | 141 | } else { |
| 142 | 142 | return $matches['0']; |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | if (!empty($matches[6])) { |
| 150 | 150 | // replacing topic_id=x |
| 151 | 151 | if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
| 152 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 152 | + $add_to_url = 'pdf-'.$mvars[1].'/'.forum_seo_topic($mvars[1]).''; |
|
| 153 | 153 | $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
| 154 | 154 | } //replacing post_id=x |
| 155 | 155 | elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
| 156 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 156 | + $add_to_url = 'pdf-'.$mvars[1].'/'.forum_seo_post($mvars[1]).''; |
|
| 157 | 157 | $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
| 158 | 158 | } else { |
| 159 | 159 | return $matches['0']; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | if ('?' === $req_string) { |
| 170 | 170 | $req_string = ''; |
| 171 | 171 | } |
| 172 | - $ret = '<' . $matches[1] . $matches[2] . $matches[3] . '=' . $matches[4] . XOOPS_URL . '/' . SEO_MODULE_NAME . '/' . $add_to_url . $req_string . $matches[7] . $matches[8] . '>'; |
|
| 172 | + $ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.SEO_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
|
| 173 | 173 | |
| 174 | 174 | //$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.REAL_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
| 175 | 175 | return $ret; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | return $ret; |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | - $query = 'SELECT cat_id, cat_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
| 193 | + $query = 'SELECT cat_id, cat_title FROM '.$GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
| 194 | 194 | $result = $GLOBALS['xoopsDB']->query($query); |
| 195 | 195 | $_ret = []; |
| 196 | 196 | while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | return $ret; |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - $query = 'SELECT forum_id, forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
| 221 | + $query = 'SELECT forum_id, forum_name FROM '.$GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
| 222 | 222 | $result = $GLOBALS['xoopsDB']->query($query); |
| 223 | 223 | $_ret = []; |
| 224 | 224 | while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | function forum_seo_topic($_cat_id) |
| 239 | 239 | { |
| 240 | - $query = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id = ' . $_cat_id; |
|
| 240 | + $query = 'SELECT topic_title FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' WHERE topic_id = '.$_cat_id; |
|
| 241 | 241 | $result = $GLOBALS['xoopsDB']->query($query); |
| 242 | 242 | $res = $GLOBALS['xoopsDB']->fetchArray($result); |
| 243 | 243 | $ret = forum_seo_title($res['topic_title']); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | function forum_seo_post($_cat_id) |
| 260 | 260 | { |
| 261 | - $query = 'SELECT subject FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $_cat_id; |
|
| 261 | + $query = 'SELECT subject FROM '.$GLOBALS['xoopsDB']->prefix('newbb_posts').' WHERE post_id = '.$_cat_id; |
|
| 262 | 262 | $result = $GLOBALS['xoopsDB']->query($query); |
| 263 | 263 | $res = $GLOBALS['xoopsDB']->fetchArray($result); |
| 264 | 264 | $ret = forum_seo_title($res['subject']); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | '', |
| 350 | 350 | '' |
| 351 | 351 | ]; |
| 352 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
| 352 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
| 353 | 353 | |
| 354 | 354 | // Transformation des caractères accentués |
| 355 | 355 | // è é ê ë ç à â ä î ï ù ü û ô ö |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | 'ae', |
| 406 | 406 | 'ss' |
| 407 | 407 | ]; |
| 408 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
| 408 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
| 409 | 409 | |
| 410 | 410 | /*$string = str_replace(' ', '-', $title); |
| 411 | 411 | $string = iconv('utf-8', 'ascii//translit', $string); |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function seo_urls($s) |
| 16 | 16 | { |
| 17 | - $XPS_URL = str_replace('/', '\/', quotemeta(XOOPS_URL)); |
|
| 18 | - $module_name = str_replace('/', '\/', quotemeta(SEO_MODULE_NAME)); |
|
| 17 | + $XPS_URL = str_replace('/', '\/', quotemeta(XOOPS_URL)); |
|
| 18 | + $module_name = str_replace('/', '\/', quotemeta(SEO_MODULE_NAME)); |
|
| 19 | 19 | |
| 20 | - $search = [ |
|
| 20 | + $search = [ |
|
| 21 | 21 | |
| 22 | - // Search URLs of modules' directry. |
|
| 23 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 24 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 25 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 26 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 27 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 28 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 29 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
| 30 | - ]; |
|
| 22 | + // Search URLs of modules' directry. |
|
| 23 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 24 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 25 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 26 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 27 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 28 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
| 29 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
| 30 | + ]; |
|
| 31 | 31 | |
| 32 | - $s = preg_replace_callback($search, 'replace_links', $s); |
|
| 32 | + $s = preg_replace_callback($search, 'replace_links', $s); |
|
| 33 | 33 | |
| 34 | - return $s; |
|
| 34 | + return $s; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,139 +40,139 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function replace_links($matches) |
| 42 | 42 | { |
| 43 | - switch ($matches[5]) { |
|
| 44 | - case 'index.php': |
|
| 45 | - $add_to_url = ''; |
|
| 46 | - $req_string = $matches[6]; |
|
| 47 | - if (!empty($matches[6])) { |
|
| 48 | - // replacing cat=x |
|
| 49 | - if (preg_match('/cat=(\d+)/', $matches[6], $mvars)) { |
|
| 50 | - $add_to_url = 'c-' . $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
| 51 | - $req_string = preg_replace('/cat=\d+/', '', $matches[6]); |
|
| 52 | - } else { |
|
| 53 | - return $matches['0']; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - break; |
|
| 57 | - case 'viewpost.php': |
|
| 58 | - $add_to_url = ''; |
|
| 59 | - $req_string = $matches[6]; |
|
| 60 | - if (!empty($matches[6])) { |
|
| 61 | - // replacing status=x |
|
| 62 | - if (preg_match('/status=([a-z]+)/', $matches[6], $mvars)) { |
|
| 63 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
| 64 | - $req_string = preg_replace('/status=([a-z])+/', '', $matches[6]); |
|
| 65 | - } else { |
|
| 66 | - return $matches['0']; |
|
| 67 | - } |
|
| 68 | - } else { |
|
| 69 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
| 70 | - } |
|
| 71 | - break; |
|
| 72 | - case 'rss.php': |
|
| 73 | - $add_to_url = ''; |
|
| 74 | - $req_string = $matches[6]; |
|
| 75 | - if (!empty($matches[6])) { |
|
| 76 | - // replacing c=x |
|
| 77 | - if (preg_match('/c=(\d+)/', $matches[6], $mvars)) { |
|
| 78 | - $add_to_url = 'rc-'; |
|
| 79 | - if ($mvars[1] > 0) { |
|
| 80 | - $add_to_url .= $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
| 81 | - } else { |
|
| 82 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
| 83 | - } |
|
| 84 | - $req_string = preg_replace('/c=\d+/', '', $matches[6]); |
|
| 85 | - } elseif (preg_match('/f=(\d+)/', $matches[6], $mvars)) { |
|
| 86 | - $add_to_url = 'rf-'; |
|
| 87 | - if ($mvars[1] > 0) { |
|
| 88 | - $add_to_url .= $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
| 89 | - } else { |
|
| 90 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
| 91 | - } |
|
| 92 | - $req_string = preg_replace('/f=\d+/', '', $matches[6]); |
|
| 93 | - } else { |
|
| 94 | - return $matches['0']; |
|
| 95 | - } |
|
| 96 | - //$add_to_url .= 'rss-feed.html'; |
|
| 97 | - } |
|
| 98 | - break; |
|
| 99 | - case 'viewforum.php': |
|
| 100 | - $add_to_url = ''; |
|
| 101 | - $req_string = $matches[6]; |
|
| 102 | - if (!empty($matches[6])) { |
|
| 103 | - // replacing forum=x |
|
| 104 | - if (preg_match('/forum=(\d+)/', $matches[6], $mvars)) { |
|
| 105 | - $add_to_url = 'f-' . $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
| 106 | - $req_string = preg_replace('/forum=\d+/', '', $matches[6]); |
|
| 107 | - } else { |
|
| 108 | - return $matches['0']; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - break; |
|
| 112 | - case 'viewtopic.php': |
|
| 113 | - $add_to_url = ''; |
|
| 114 | - $req_string = $matches[6]; |
|
| 115 | - if (!empty($matches[6])) { |
|
| 116 | - // replacing topic_id=x |
|
| 117 | - if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
| 118 | - $add_to_url = 't-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 119 | - $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
| 120 | - } //replacing post_id=x |
|
| 121 | - elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
| 122 | - $add_to_url = 'p-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 123 | - $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
| 124 | - } else { |
|
| 125 | - return $matches['0']; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - break; |
|
| 129 | - case 'print.php': |
|
| 130 | - $add_to_url = ''; |
|
| 131 | - $req_string = $matches[6]; |
|
| 132 | - if (!empty($matches[6])) { |
|
| 133 | - // replacing topic_id=x |
|
| 134 | - if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
| 135 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 136 | - $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
| 137 | - } //replacing post_id=x |
|
| 138 | - elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
| 139 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 140 | - $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
| 141 | - } else { |
|
| 142 | - return $matches['0']; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - break; |
|
| 146 | - case 'makepdf.php': |
|
| 147 | - $add_to_url = ''; |
|
| 148 | - $req_string = $matches[6]; |
|
| 149 | - if (!empty($matches[6])) { |
|
| 150 | - // replacing topic_id=x |
|
| 151 | - if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
| 152 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 153 | - $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
| 154 | - } //replacing post_id=x |
|
| 155 | - elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
| 156 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 157 | - $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
| 158 | - } else { |
|
| 159 | - return $matches['0']; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - break; |
|
| 163 | - default: |
|
| 164 | - $req_string = $matches[6]; |
|
| 165 | - $add_to_url = $matches[5]; |
|
| 166 | - //if ($add_to_url === '') $add_to_url ='index.php'; |
|
| 167 | - break; |
|
| 168 | - } |
|
| 169 | - if ('?' === $req_string) { |
|
| 170 | - $req_string = ''; |
|
| 171 | - } |
|
| 172 | - $ret = '<' . $matches[1] . $matches[2] . $matches[3] . '=' . $matches[4] . XOOPS_URL . '/' . SEO_MODULE_NAME . '/' . $add_to_url . $req_string . $matches[7] . $matches[8] . '>'; |
|
| 43 | + switch ($matches[5]) { |
|
| 44 | + case 'index.php': |
|
| 45 | + $add_to_url = ''; |
|
| 46 | + $req_string = $matches[6]; |
|
| 47 | + if (!empty($matches[6])) { |
|
| 48 | + // replacing cat=x |
|
| 49 | + if (preg_match('/cat=(\d+)/', $matches[6], $mvars)) { |
|
| 50 | + $add_to_url = 'c-' . $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
| 51 | + $req_string = preg_replace('/cat=\d+/', '', $matches[6]); |
|
| 52 | + } else { |
|
| 53 | + return $matches['0']; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + break; |
|
| 57 | + case 'viewpost.php': |
|
| 58 | + $add_to_url = ''; |
|
| 59 | + $req_string = $matches[6]; |
|
| 60 | + if (!empty($matches[6])) { |
|
| 61 | + // replacing status=x |
|
| 62 | + if (preg_match('/status=([a-z]+)/', $matches[6], $mvars)) { |
|
| 63 | + $add_to_url = 'viewpost.php' . $matches[6]; |
|
| 64 | + $req_string = preg_replace('/status=([a-z])+/', '', $matches[6]); |
|
| 65 | + } else { |
|
| 66 | + return $matches['0']; |
|
| 67 | + } |
|
| 68 | + } else { |
|
| 69 | + $add_to_url = 'viewpost.php' . $matches[6]; |
|
| 70 | + } |
|
| 71 | + break; |
|
| 72 | + case 'rss.php': |
|
| 73 | + $add_to_url = ''; |
|
| 74 | + $req_string = $matches[6]; |
|
| 75 | + if (!empty($matches[6])) { |
|
| 76 | + // replacing c=x |
|
| 77 | + if (preg_match('/c=(\d+)/', $matches[6], $mvars)) { |
|
| 78 | + $add_to_url = 'rc-'; |
|
| 79 | + if ($mvars[1] > 0) { |
|
| 80 | + $add_to_url .= $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
| 81 | + } else { |
|
| 82 | + $add_to_url .= $mvars[1] . '/rss.html'; |
|
| 83 | + } |
|
| 84 | + $req_string = preg_replace('/c=\d+/', '', $matches[6]); |
|
| 85 | + } elseif (preg_match('/f=(\d+)/', $matches[6], $mvars)) { |
|
| 86 | + $add_to_url = 'rf-'; |
|
| 87 | + if ($mvars[1] > 0) { |
|
| 88 | + $add_to_url .= $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
| 89 | + } else { |
|
| 90 | + $add_to_url .= $mvars[1] . '/rss.html'; |
|
| 91 | + } |
|
| 92 | + $req_string = preg_replace('/f=\d+/', '', $matches[6]); |
|
| 93 | + } else { |
|
| 94 | + return $matches['0']; |
|
| 95 | + } |
|
| 96 | + //$add_to_url .= 'rss-feed.html'; |
|
| 97 | + } |
|
| 98 | + break; |
|
| 99 | + case 'viewforum.php': |
|
| 100 | + $add_to_url = ''; |
|
| 101 | + $req_string = $matches[6]; |
|
| 102 | + if (!empty($matches[6])) { |
|
| 103 | + // replacing forum=x |
|
| 104 | + if (preg_match('/forum=(\d+)/', $matches[6], $mvars)) { |
|
| 105 | + $add_to_url = 'f-' . $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
| 106 | + $req_string = preg_replace('/forum=\d+/', '', $matches[6]); |
|
| 107 | + } else { |
|
| 108 | + return $matches['0']; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + break; |
|
| 112 | + case 'viewtopic.php': |
|
| 113 | + $add_to_url = ''; |
|
| 114 | + $req_string = $matches[6]; |
|
| 115 | + if (!empty($matches[6])) { |
|
| 116 | + // replacing topic_id=x |
|
| 117 | + if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
| 118 | + $add_to_url = 't-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 119 | + $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
| 120 | + } //replacing post_id=x |
|
| 121 | + elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
| 122 | + $add_to_url = 'p-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 123 | + $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
| 124 | + } else { |
|
| 125 | + return $matches['0']; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + break; |
|
| 129 | + case 'print.php': |
|
| 130 | + $add_to_url = ''; |
|
| 131 | + $req_string = $matches[6]; |
|
| 132 | + if (!empty($matches[6])) { |
|
| 133 | + // replacing topic_id=x |
|
| 134 | + if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
| 135 | + $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 136 | + $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
| 137 | + } //replacing post_id=x |
|
| 138 | + elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
| 139 | + $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 140 | + $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
| 141 | + } else { |
|
| 142 | + return $matches['0']; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + break; |
|
| 146 | + case 'makepdf.php': |
|
| 147 | + $add_to_url = ''; |
|
| 148 | + $req_string = $matches[6]; |
|
| 149 | + if (!empty($matches[6])) { |
|
| 150 | + // replacing topic_id=x |
|
| 151 | + if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
| 152 | + $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
| 153 | + $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
| 154 | + } //replacing post_id=x |
|
| 155 | + elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
| 156 | + $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
| 157 | + $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
| 158 | + } else { |
|
| 159 | + return $matches['0']; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + break; |
|
| 163 | + default: |
|
| 164 | + $req_string = $matches[6]; |
|
| 165 | + $add_to_url = $matches[5]; |
|
| 166 | + //if ($add_to_url === '') $add_to_url ='index.php'; |
|
| 167 | + break; |
|
| 168 | + } |
|
| 169 | + if ('?' === $req_string) { |
|
| 170 | + $req_string = ''; |
|
| 171 | + } |
|
| 172 | + $ret = '<' . $matches[1] . $matches[2] . $matches[3] . '=' . $matches[4] . XOOPS_URL . '/' . SEO_MODULE_NAME . '/' . $add_to_url . $req_string . $matches[7] . $matches[8] . '>'; |
|
| 173 | 173 | |
| 174 | - //$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.REAL_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
|
| 175 | - return $ret; |
|
| 174 | + //$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.REAL_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
|
| 175 | + return $ret; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -181,26 +181,26 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | function forum_seo_cat($_cat_id) |
| 183 | 183 | { |
| 184 | - xoops_load('XoopsCache'); |
|
| 185 | - $key = 'newbb_seo_cat'; |
|
| 186 | - $ret = false; |
|
| 187 | - if ($ret = \XoopsCache::read($key)) { |
|
| 188 | - $ret = @$ret[$_cat_id]; |
|
| 189 | - if ($ret) { |
|
| 190 | - return $ret; |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - $query = 'SELECT cat_id, cat_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
| 194 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
| 195 | - $_ret = []; |
|
| 196 | - while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
| 197 | - $_ret[$res['cat_id']] = forum_seo_title($res['cat_title']); |
|
| 198 | - } |
|
| 199 | - XoopsCache::write($key, $_ret); |
|
| 200 | - $ret = \XoopsCache::read($key); |
|
| 201 | - $ret = $ret[$_cat_id]; |
|
| 184 | + xoops_load('XoopsCache'); |
|
| 185 | + $key = 'newbb_seo_cat'; |
|
| 186 | + $ret = false; |
|
| 187 | + if ($ret = \XoopsCache::read($key)) { |
|
| 188 | + $ret = @$ret[$_cat_id]; |
|
| 189 | + if ($ret) { |
|
| 190 | + return $ret; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + $query = 'SELECT cat_id, cat_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
| 194 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
| 195 | + $_ret = []; |
|
| 196 | + while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
| 197 | + $_ret[$res['cat_id']] = forum_seo_title($res['cat_title']); |
|
| 198 | + } |
|
| 199 | + XoopsCache::write($key, $_ret); |
|
| 200 | + $ret = \XoopsCache::read($key); |
|
| 201 | + $ret = $ret[$_cat_id]; |
|
| 202 | 202 | |
| 203 | - return $ret; |
|
| 203 | + return $ret; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -209,26 +209,26 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | function forum_seo_forum($_cat_id) |
| 211 | 211 | { |
| 212 | - xoops_load('XoopsCache'); |
|
| 213 | - $key = 'newbb_seo_forum'; |
|
| 214 | - $ret = false; |
|
| 215 | - if ($ret = \XoopsCache::read($key)) { |
|
| 216 | - $ret = @$ret[$_cat_id]; |
|
| 217 | - if ($ret) { |
|
| 218 | - return $ret; |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - $query = 'SELECT forum_id, forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
| 222 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
| 223 | - $_ret = []; |
|
| 224 | - while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
| 225 | - $_ret[$res['forum_id']] = forum_seo_title($res['forum_name']); |
|
| 226 | - } |
|
| 227 | - XoopsCache::write($key, $_ret); |
|
| 228 | - $ret = \XoopsCache::read($key); |
|
| 229 | - $ret = $ret[$_cat_id]; |
|
| 212 | + xoops_load('XoopsCache'); |
|
| 213 | + $key = 'newbb_seo_forum'; |
|
| 214 | + $ret = false; |
|
| 215 | + if ($ret = \XoopsCache::read($key)) { |
|
| 216 | + $ret = @$ret[$_cat_id]; |
|
| 217 | + if ($ret) { |
|
| 218 | + return $ret; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + $query = 'SELECT forum_id, forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
| 222 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
| 223 | + $_ret = []; |
|
| 224 | + while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
| 225 | + $_ret[$res['forum_id']] = forum_seo_title($res['forum_name']); |
|
| 226 | + } |
|
| 227 | + XoopsCache::write($key, $_ret); |
|
| 228 | + $ret = \XoopsCache::read($key); |
|
| 229 | + $ret = $ret[$_cat_id]; |
|
| 230 | 230 | |
| 231 | - return $ret; |
|
| 231 | + return $ret; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -237,19 +237,19 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | function forum_seo_topic($_cat_id) |
| 239 | 239 | { |
| 240 | - $query = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id = ' . $_cat_id; |
|
| 241 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
| 242 | - $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
| 243 | - $ret = forum_seo_title($res['topic_title']); |
|
| 240 | + $query = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id = ' . $_cat_id; |
|
| 241 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
| 242 | + $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
| 243 | + $ret = forum_seo_title($res['topic_title']); |
|
| 244 | 244 | |
| 245 | - $moduleDirName = basename(__DIR__); |
|
| 246 | - /** @var Newbb\TopicHandler $topicsHandler */ |
|
| 247 | - $topicsHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
| 248 | - $criteria = new \CriteriaCompo(new \Criteria('topic_id', $_cat_id, '=')); |
|
| 249 | - $fields = ['topic_title']; |
|
| 250 | - $ret0 = $topicsHandler->getAll($criteria, $fields, false); |
|
| 245 | + $moduleDirName = basename(__DIR__); |
|
| 246 | + /** @var Newbb\TopicHandler $topicsHandler */ |
|
| 247 | + $topicsHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
| 248 | + $criteria = new \CriteriaCompo(new \Criteria('topic_id', $_cat_id, '=')); |
|
| 249 | + $fields = ['topic_title']; |
|
| 250 | + $ret0 = $topicsHandler->getAll($criteria, $fields, false); |
|
| 251 | 251 | |
| 252 | - return $ret; |
|
| 252 | + return $ret; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | function forum_seo_post($_cat_id) |
| 260 | 260 | { |
| 261 | - $query = 'SELECT subject FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $_cat_id; |
|
| 262 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
| 263 | - $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
| 264 | - $ret = forum_seo_title($res['subject']); |
|
| 261 | + $query = 'SELECT subject FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $_cat_id; |
|
| 262 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
| 263 | + $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
| 264 | + $ret = forum_seo_title($res['subject']); |
|
| 265 | 265 | |
| 266 | - return $ret; |
|
| 266 | + return $ret; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -273,152 +273,152 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | function forum_seo_title($title = '', $withExt = true) |
| 275 | 275 | { |
| 276 | - /** |
|
| 277 | - * if XOOPS ML is present, let's sanitize the title with the current language |
|
| 278 | - */ |
|
| 279 | - $myts = \MyTextSanitizer::getInstance(); |
|
| 280 | - if (method_exists($myts, 'formatForML')) { |
|
| 281 | - $title = $myts->formatForML($title); |
|
| 282 | - } |
|
| 276 | + /** |
|
| 277 | + * if XOOPS ML is present, let's sanitize the title with the current language |
|
| 278 | + */ |
|
| 279 | + $myts = \MyTextSanitizer::getInstance(); |
|
| 280 | + if (method_exists($myts, 'formatForML')) { |
|
| 281 | + $title = $myts->formatForML($title); |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - // Transformation de la chaine en minuscule |
|
| 285 | - // Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus |
|
| 286 | - $title = rawurlencode(strtolower($title)); |
|
| 284 | + // Transformation de la chaine en minuscule |
|
| 285 | + // Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus |
|
| 286 | + $title = rawurlencode(strtolower($title)); |
|
| 287 | 287 | |
| 288 | - // Transformation des ponctuations |
|
| 289 | - // Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ . |
|
| 290 | - $pattern = [ |
|
| 291 | - '/%09/', |
|
| 292 | - '/%20/', |
|
| 293 | - '/%21/', |
|
| 294 | - '/%22/', |
|
| 295 | - '/%23/', |
|
| 296 | - '/%25/', |
|
| 297 | - '/%26/', |
|
| 298 | - '/%27/', |
|
| 299 | - '/%28/', |
|
| 300 | - '/%29/', |
|
| 301 | - '/%2C/', |
|
| 302 | - '/%2F/', |
|
| 303 | - '/%3A/', |
|
| 304 | - '/%3B/', |
|
| 305 | - '/%3C/', |
|
| 306 | - '/%3D/', |
|
| 307 | - '/%3E/', |
|
| 308 | - '/%3F/', |
|
| 309 | - '/%40/', |
|
| 310 | - '/%5B/', |
|
| 311 | - '/%5C/', |
|
| 312 | - '/%5D/', |
|
| 313 | - '/%5E/', |
|
| 314 | - '/%7B/', |
|
| 315 | - '/%7C/', |
|
| 316 | - '/%7D/', |
|
| 317 | - '/%7E/', |
|
| 318 | - '/\./', |
|
| 319 | - '/%2A/' |
|
| 320 | - ]; |
|
| 321 | - $rep_pat = [ |
|
| 322 | - '-', |
|
| 323 | - '-', |
|
| 324 | - '', |
|
| 325 | - '', |
|
| 326 | - '', |
|
| 327 | - '-100', |
|
| 328 | - '', |
|
| 329 | - '-', |
|
| 330 | - '', |
|
| 331 | - '', |
|
| 332 | - '', |
|
| 333 | - '-', |
|
| 334 | - '', |
|
| 335 | - '', |
|
| 336 | - '', |
|
| 337 | - '-', |
|
| 338 | - '', |
|
| 339 | - '', |
|
| 340 | - '-at-', |
|
| 341 | - '', |
|
| 342 | - '-', |
|
| 343 | - '', |
|
| 344 | - '-', |
|
| 345 | - '', |
|
| 346 | - '-', |
|
| 347 | - '', |
|
| 348 | - '-', |
|
| 349 | - '', |
|
| 350 | - '' |
|
| 351 | - ]; |
|
| 352 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
| 288 | + // Transformation des ponctuations |
|
| 289 | + // Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ . |
|
| 290 | + $pattern = [ |
|
| 291 | + '/%09/', |
|
| 292 | + '/%20/', |
|
| 293 | + '/%21/', |
|
| 294 | + '/%22/', |
|
| 295 | + '/%23/', |
|
| 296 | + '/%25/', |
|
| 297 | + '/%26/', |
|
| 298 | + '/%27/', |
|
| 299 | + '/%28/', |
|
| 300 | + '/%29/', |
|
| 301 | + '/%2C/', |
|
| 302 | + '/%2F/', |
|
| 303 | + '/%3A/', |
|
| 304 | + '/%3B/', |
|
| 305 | + '/%3C/', |
|
| 306 | + '/%3D/', |
|
| 307 | + '/%3E/', |
|
| 308 | + '/%3F/', |
|
| 309 | + '/%40/', |
|
| 310 | + '/%5B/', |
|
| 311 | + '/%5C/', |
|
| 312 | + '/%5D/', |
|
| 313 | + '/%5E/', |
|
| 314 | + '/%7B/', |
|
| 315 | + '/%7C/', |
|
| 316 | + '/%7D/', |
|
| 317 | + '/%7E/', |
|
| 318 | + '/\./', |
|
| 319 | + '/%2A/' |
|
| 320 | + ]; |
|
| 321 | + $rep_pat = [ |
|
| 322 | + '-', |
|
| 323 | + '-', |
|
| 324 | + '', |
|
| 325 | + '', |
|
| 326 | + '', |
|
| 327 | + '-100', |
|
| 328 | + '', |
|
| 329 | + '-', |
|
| 330 | + '', |
|
| 331 | + '', |
|
| 332 | + '', |
|
| 333 | + '-', |
|
| 334 | + '', |
|
| 335 | + '', |
|
| 336 | + '', |
|
| 337 | + '-', |
|
| 338 | + '', |
|
| 339 | + '', |
|
| 340 | + '-at-', |
|
| 341 | + '', |
|
| 342 | + '-', |
|
| 343 | + '', |
|
| 344 | + '-', |
|
| 345 | + '', |
|
| 346 | + '-', |
|
| 347 | + '', |
|
| 348 | + '-', |
|
| 349 | + '', |
|
| 350 | + '' |
|
| 351 | + ]; |
|
| 352 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
| 353 | 353 | |
| 354 | - // Transformation des caractères accentués |
|
| 355 | - // è é ê ë ç à â ä î ï ù ü û ô ö |
|
| 356 | - $pattern = [ |
|
| 357 | - '/%B0/', |
|
| 358 | - '/%E8/', |
|
| 359 | - '/%E9/', |
|
| 360 | - '/%EA/', |
|
| 361 | - '/%EB/', |
|
| 362 | - '/%E7/', |
|
| 363 | - '/%E0/', |
|
| 364 | - '/%E2/', |
|
| 365 | - '/%E4/', |
|
| 366 | - '/%EE/', |
|
| 367 | - '/%EF/', |
|
| 368 | - '/%F9/', |
|
| 369 | - '/%FC/', |
|
| 370 | - '/%FB/', |
|
| 371 | - '/%F4/', |
|
| 372 | - '/%F6/', |
|
| 373 | - '/%E3%BC/', |
|
| 374 | - '/%E3%96/', |
|
| 375 | - '/%E3%84/', |
|
| 376 | - '/%E3%9C/', |
|
| 377 | - '/%E3%FF/', |
|
| 378 | - '/%E3%B6/', |
|
| 379 | - '/%E3%A4/', |
|
| 380 | - '/%E3%9F/' |
|
| 381 | - ]; |
|
| 382 | - $rep_pat = [ |
|
| 383 | - '-', |
|
| 384 | - 'e', |
|
| 385 | - 'e', |
|
| 386 | - 'e', |
|
| 387 | - 'e', |
|
| 388 | - 'c', |
|
| 389 | - 'a', |
|
| 390 | - 'a', |
|
| 391 | - 'a', |
|
| 392 | - 'i', |
|
| 393 | - 'i', |
|
| 394 | - 'u', |
|
| 395 | - 'u', |
|
| 396 | - 'u', |
|
| 397 | - 'o', |
|
| 398 | - 'o', |
|
| 399 | - 'ue', |
|
| 400 | - 'oe', |
|
| 401 | - 'ae', |
|
| 402 | - 'ue', |
|
| 403 | - 'ss', |
|
| 404 | - 'oe', |
|
| 405 | - 'ae', |
|
| 406 | - 'ss' |
|
| 407 | - ]; |
|
| 408 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
| 354 | + // Transformation des caractères accentués |
|
| 355 | + // è é ê ë ç à â ä î ï ù ü û ô ö |
|
| 356 | + $pattern = [ |
|
| 357 | + '/%B0/', |
|
| 358 | + '/%E8/', |
|
| 359 | + '/%E9/', |
|
| 360 | + '/%EA/', |
|
| 361 | + '/%EB/', |
|
| 362 | + '/%E7/', |
|
| 363 | + '/%E0/', |
|
| 364 | + '/%E2/', |
|
| 365 | + '/%E4/', |
|
| 366 | + '/%EE/', |
|
| 367 | + '/%EF/', |
|
| 368 | + '/%F9/', |
|
| 369 | + '/%FC/', |
|
| 370 | + '/%FB/', |
|
| 371 | + '/%F4/', |
|
| 372 | + '/%F6/', |
|
| 373 | + '/%E3%BC/', |
|
| 374 | + '/%E3%96/', |
|
| 375 | + '/%E3%84/', |
|
| 376 | + '/%E3%9C/', |
|
| 377 | + '/%E3%FF/', |
|
| 378 | + '/%E3%B6/', |
|
| 379 | + '/%E3%A4/', |
|
| 380 | + '/%E3%9F/' |
|
| 381 | + ]; |
|
| 382 | + $rep_pat = [ |
|
| 383 | + '-', |
|
| 384 | + 'e', |
|
| 385 | + 'e', |
|
| 386 | + 'e', |
|
| 387 | + 'e', |
|
| 388 | + 'c', |
|
| 389 | + 'a', |
|
| 390 | + 'a', |
|
| 391 | + 'a', |
|
| 392 | + 'i', |
|
| 393 | + 'i', |
|
| 394 | + 'u', |
|
| 395 | + 'u', |
|
| 396 | + 'u', |
|
| 397 | + 'o', |
|
| 398 | + 'o', |
|
| 399 | + 'ue', |
|
| 400 | + 'oe', |
|
| 401 | + 'ae', |
|
| 402 | + 'ue', |
|
| 403 | + 'ss', |
|
| 404 | + 'oe', |
|
| 405 | + 'ae', |
|
| 406 | + 'ss' |
|
| 407 | + ]; |
|
| 408 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
| 409 | 409 | |
| 410 | - /*$string = str_replace(' ', '-', $title); |
|
| 410 | + /*$string = str_replace(' ', '-', $title); |
|
| 411 | 411 | $string = iconv('utf-8', 'ascii//translit', $string); |
| 412 | 412 | $string = preg_replace('#[^a-z0-9\-\.]#si', '', $string); |
| 413 | 413 | $title = str_replace('\/','', $string); */ |
| 414 | 414 | |
| 415 | - if (count($title) > 0) { |
|
| 416 | - if ($withExt) { |
|
| 417 | - $title .= '.html'; |
|
| 418 | - } |
|
| 415 | + if (count($title) > 0) { |
|
| 416 | + if ($withExt) { |
|
| 417 | + $title .= '.html'; |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - return $title; |
|
| 421 | - } |
|
| 420 | + return $title; |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - return ''; |
|
| 423 | + return ''; |
|
| 424 | 424 | } |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | $criteriaPost = new \CriteriaCompo(); |
| 56 | 56 | $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts |
| 57 | 57 | |
| 58 | - $forum_list = [];// get forum lists just for forum names |
|
| 58 | + $forum_list = []; // get forum lists just for forum names |
|
| 59 | 59 | if (count($validForums) > 0) { |
| 60 | 60 | $criteriaPermissions = new \CriteriaCompo(); |
| 61 | - $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND'); |
|
| 62 | - $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false); |
|
| 61 | + $criteriaPermissions->add(new \Criteria('p.forum_id', '('.implode(',', $validForums).')', 'IN'), 'AND'); |
|
| 62 | + $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '('.implode(', ', $validForums).')', 'IN'), 'forum_name', false); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if (is_numeric($userid) && 0 !== $userid) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } elseif (is_array($userid) && count($userid) > 0) { |
| 69 | 69 | $userid = array_map('intval', $userid); |
| 70 | 70 | $criteriaUser = new \CriteriaCompo(); |
| 71 | - $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR'); |
|
| 71 | + $criteriaUser->add(new \Criteria('p.uid', '('.implode(',', $userid).')', 'IN'), 'OR'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $count = 0; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $criteriaKeywords = new \CriteriaCompo(); |
| 81 | 81 | foreach ($queryarray as $queryTerm) { |
| 82 | 82 | $termCriteria = new \CriteriaCompo(); |
| 83 | - $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%'; |
|
| 83 | + $queryTermLike = '%'.$xoopsDB->escape($queryTerm).'%'; |
|
| 84 | 84 | if ('title' === $searchin || 'both' === $searchin) { |
| 85 | 85 | $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR'); |
| 86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $criteriaKeywords->add($termCriteria, $andor); |
| 91 | 91 | } |
| 92 | 92 | // add highlight keywords to post links |
| 93 | - $highlightKey = '&keywords=' . implode(' ', $queryarray); |
|
| 93 | + $highlightKey = '&keywords='.implode(' ', $queryarray); |
|
| 94 | 94 | $highlightKey = str_replace(' ', '+', $highlightKey); |
| 95 | 95 | } |
| 96 | 96 | $criteria = new \CriteriaCompo(); |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $post = $posts[$id]; |
| 132 | 132 | $post_data = $post->getPostBody(); |
| 133 | 133 | $ret[$i]['topic_id'] = $post->getVar('topic_id'); |
| 134 | - $ret[$i]['link'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key |
|
| 134 | + $ret[$i]['link'] = XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$post->getVar('post_id').$highlightKey; // add highlight key |
|
| 135 | 135 | $ret[$i]['title'] = $post_data['subject']; |
| 136 | 136 | $ret[$i]['time'] = $post_data['date']; |
| 137 | 137 | $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']); |
| 138 | - $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id'); |
|
| 138 | + $ret[$i]['forum_link'] = XOOPS_URL.'/modules/newbb/viewforum.php?forum='.$post->getVar('forum_id'); |
|
| 139 | 139 | $ret[$i]['post_text'] = $post_data['text']; |
| 140 | 140 | $ret[$i]['uid'] = $post->getVar('uid'); |
| 141 | - $ret[$i]['poster'] = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author']; |
|
| 141 | + $ret[$i]['poster'] = $post->getVar('uid') ? '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$ret[$i]['uid'].'">'.$post_data['author'].'</a>' : $post_data['author']; |
|
| 142 | 142 | ++$i; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -28,119 +28,119 @@ |
||
| 28 | 28 | * @return array |
| 29 | 29 | */ |
| 30 | 30 | function newbb_search( |
| 31 | - $queryarray, |
|
| 32 | - $andor, |
|
| 33 | - $limit, |
|
| 34 | - $offset, |
|
| 35 | - $userid, |
|
| 36 | - $forums = 0, |
|
| 37 | - $sortby = 0, |
|
| 38 | - $searchin = 'both', |
|
| 39 | - CriteriaCompo $criteriaExtra = null |
|
| 31 | + $queryarray, |
|
| 32 | + $andor, |
|
| 33 | + $limit, |
|
| 34 | + $offset, |
|
| 35 | + $userid, |
|
| 36 | + $forums = 0, |
|
| 37 | + $sortby = 0, |
|
| 38 | + $searchin = 'both', |
|
| 39 | + CriteriaCompo $criteriaExtra = null |
|
| 40 | 40 | ) { |
| 41 | - global $myts, $xoopsDB; |
|
| 42 | - // irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set |
|
| 43 | - if (!isset($GLOBALS['xoopsModuleConfig'])) { |
|
| 44 | - $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig(); |
|
| 45 | - } |
|
| 46 | - // irmtfan - in XOOPSCORE/search.php $xoopsModule is not set |
|
| 47 | - if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module']) |
|
| 48 | - && 'newbb' === $GLOBALS['module']->getVar('dirname')) { |
|
| 49 | - $GLOBALS['xoopsModule'] = $GLOBALS['module']; |
|
| 50 | - } |
|
| 51 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
| 52 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
| 53 | - $validForums = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view") |
|
| 41 | + global $myts, $xoopsDB; |
|
| 42 | + // irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set |
|
| 43 | + if (!isset($GLOBALS['xoopsModuleConfig'])) { |
|
| 44 | + $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig(); |
|
| 45 | + } |
|
| 46 | + // irmtfan - in XOOPSCORE/search.php $xoopsModule is not set |
|
| 47 | + if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module']) |
|
| 48 | + && 'newbb' === $GLOBALS['module']->getVar('dirname')) { |
|
| 49 | + $GLOBALS['xoopsModule'] = $GLOBALS['module']; |
|
| 50 | + } |
|
| 51 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
| 52 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
| 53 | + $validForums = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view") |
|
| 54 | 54 | |
| 55 | - $criteriaPost = new \CriteriaCompo(); |
|
| 56 | - $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts |
|
| 55 | + $criteriaPost = new \CriteriaCompo(); |
|
| 56 | + $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts |
|
| 57 | 57 | |
| 58 | - $forum_list = [];// get forum lists just for forum names |
|
| 59 | - if (count($validForums) > 0) { |
|
| 60 | - $criteriaPermissions = new \CriteriaCompo(); |
|
| 61 | - $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND'); |
|
| 62 | - $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false); |
|
| 63 | - } |
|
| 58 | + $forum_list = [];// get forum lists just for forum names |
|
| 59 | + if (count($validForums) > 0) { |
|
| 60 | + $criteriaPermissions = new \CriteriaCompo(); |
|
| 61 | + $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND'); |
|
| 62 | + $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - if (is_numeric($userid) && 0 !== $userid) { |
|
| 66 | - $criteriaUser = new \CriteriaCompo(); |
|
| 67 | - $criteriaUser->add(new \Criteria('p.uid', $userid), 'OR'); |
|
| 68 | - } elseif (is_array($userid) && count($userid) > 0) { |
|
| 69 | - $userid = array_map('intval', $userid); |
|
| 70 | - $criteriaUser = new \CriteriaCompo(); |
|
| 71 | - $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR'); |
|
| 72 | - } |
|
| 65 | + if (is_numeric($userid) && 0 !== $userid) { |
|
| 66 | + $criteriaUser = new \CriteriaCompo(); |
|
| 67 | + $criteriaUser->add(new \Criteria('p.uid', $userid), 'OR'); |
|
| 68 | + } elseif (is_array($userid) && count($userid) > 0) { |
|
| 69 | + $userid = array_map('intval', $userid); |
|
| 70 | + $criteriaUser = new \CriteriaCompo(); |
|
| 71 | + $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR'); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $count = 0; |
|
| 75 | - if (is_array($queryarray)) { |
|
| 76 | - $count = count($queryarray); |
|
| 77 | - } |
|
| 78 | - $highlightKey = ''; |
|
| 79 | - if ($count > 0) { |
|
| 80 | - $criteriaKeywords = new \CriteriaCompo(); |
|
| 81 | - foreach ($queryarray as $queryTerm) { |
|
| 82 | - $termCriteria = new \CriteriaCompo(); |
|
| 83 | - $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%'; |
|
| 84 | - if ('title' === $searchin || 'both' === $searchin) { |
|
| 85 | - $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR'); |
|
| 86 | - } |
|
| 87 | - if ('text' === $searchin || 'both' === $searchin) { |
|
| 88 | - $termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR'); |
|
| 89 | - } |
|
| 90 | - $criteriaKeywords->add($termCriteria, $andor); |
|
| 91 | - } |
|
| 92 | - // add highlight keywords to post links |
|
| 93 | - $highlightKey = '&keywords=' . implode(' ', $queryarray); |
|
| 94 | - $highlightKey = str_replace(' ', '+', $highlightKey); |
|
| 95 | - } |
|
| 96 | - $criteria = new \CriteriaCompo(); |
|
| 97 | - $criteria->add($criteriaPost, 'AND'); |
|
| 98 | - if (null !== $criteriaPermissions) { |
|
| 99 | - $criteria->add($criteriaPermissions, 'AND'); |
|
| 100 | - } |
|
| 101 | - if (isset($criteriaUser)) { |
|
| 102 | - $criteria->add($criteriaUser, 'AND'); |
|
| 103 | - } |
|
| 104 | - if (isset($criteriaKeywords)) { |
|
| 105 | - $criteria->add($criteriaKeywords, 'AND'); |
|
| 106 | - } |
|
| 107 | - if (isset($criteriaExtra)) { |
|
| 108 | - $criteria->add($criteriaExtra, 'AND'); |
|
| 109 | - } |
|
| 110 | - //$criteria->setLimit($limit); // no need for this |
|
| 111 | - //$criteria->setStart($offset); // no need for this |
|
| 74 | + $count = 0; |
|
| 75 | + if (is_array($queryarray)) { |
|
| 76 | + $count = count($queryarray); |
|
| 77 | + } |
|
| 78 | + $highlightKey = ''; |
|
| 79 | + if ($count > 0) { |
|
| 80 | + $criteriaKeywords = new \CriteriaCompo(); |
|
| 81 | + foreach ($queryarray as $queryTerm) { |
|
| 82 | + $termCriteria = new \CriteriaCompo(); |
|
| 83 | + $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%'; |
|
| 84 | + if ('title' === $searchin || 'both' === $searchin) { |
|
| 85 | + $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR'); |
|
| 86 | + } |
|
| 87 | + if ('text' === $searchin || 'both' === $searchin) { |
|
| 88 | + $termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR'); |
|
| 89 | + } |
|
| 90 | + $criteriaKeywords->add($termCriteria, $andor); |
|
| 91 | + } |
|
| 92 | + // add highlight keywords to post links |
|
| 93 | + $highlightKey = '&keywords=' . implode(' ', $queryarray); |
|
| 94 | + $highlightKey = str_replace(' ', '+', $highlightKey); |
|
| 95 | + } |
|
| 96 | + $criteria = new \CriteriaCompo(); |
|
| 97 | + $criteria->add($criteriaPost, 'AND'); |
|
| 98 | + if (null !== $criteriaPermissions) { |
|
| 99 | + $criteria->add($criteriaPermissions, 'AND'); |
|
| 100 | + } |
|
| 101 | + if (isset($criteriaUser)) { |
|
| 102 | + $criteria->add($criteriaUser, 'AND'); |
|
| 103 | + } |
|
| 104 | + if (isset($criteriaKeywords)) { |
|
| 105 | + $criteria->add($criteriaKeywords, 'AND'); |
|
| 106 | + } |
|
| 107 | + if (isset($criteriaExtra)) { |
|
| 108 | + $criteria->add($criteriaExtra, 'AND'); |
|
| 109 | + } |
|
| 110 | + //$criteria->setLimit($limit); // no need for this |
|
| 111 | + //$criteria->setStart($offset); // no need for this |
|
| 112 | 112 | |
| 113 | - if (empty($sortby)) { |
|
| 114 | - $sortby = 'p.post_time'; |
|
| 115 | - } |
|
| 116 | - $criteria->setSort($sortby); |
|
| 117 | - $order = 'ASC'; |
|
| 118 | - if ('p.post_time' === $sortby) { |
|
| 119 | - $order = 'DESC'; |
|
| 120 | - } |
|
| 121 | - $criteria->setOrder($order); |
|
| 113 | + if (empty($sortby)) { |
|
| 114 | + $sortby = 'p.post_time'; |
|
| 115 | + } |
|
| 116 | + $criteria->setSort($sortby); |
|
| 117 | + $order = 'ASC'; |
|
| 118 | + if ('p.post_time' === $sortby) { |
|
| 119 | + $order = 'DESC'; |
|
| 120 | + } |
|
| 121 | + $criteria->setOrder($order); |
|
| 122 | 122 | |
| 123 | - /** @var Newbb\PostHandler $postHandler */ |
|
| 124 | - $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
| 125 | - $posts = $postHandler->getPostsByLimit($criteria, $limit, $offset); |
|
| 123 | + /** @var Newbb\PostHandler $postHandler */ |
|
| 124 | + $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
| 125 | + $posts = $postHandler->getPostsByLimit($criteria, $limit, $offset); |
|
| 126 | 126 | |
| 127 | - $ret = []; |
|
| 128 | - $i = 0; |
|
| 129 | - foreach (array_keys($posts) as $id) { |
|
| 130 | - /** @var Newbb\Post $post */ |
|
| 131 | - $post = $posts[$id]; |
|
| 132 | - $post_data = $post->getPostBody(); |
|
| 133 | - $ret[$i]['topic_id'] = $post->getVar('topic_id'); |
|
| 134 | - $ret[$i]['link'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key |
|
| 135 | - $ret[$i]['title'] = $post_data['subject']; |
|
| 136 | - $ret[$i]['time'] = $post_data['date']; |
|
| 137 | - $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']); |
|
| 138 | - $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id'); |
|
| 139 | - $ret[$i]['post_text'] = $post_data['text']; |
|
| 140 | - $ret[$i]['uid'] = $post->getVar('uid'); |
|
| 141 | - $ret[$i]['poster'] = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author']; |
|
| 142 | - ++$i; |
|
| 143 | - } |
|
| 127 | + $ret = []; |
|
| 128 | + $i = 0; |
|
| 129 | + foreach (array_keys($posts) as $id) { |
|
| 130 | + /** @var Newbb\Post $post */ |
|
| 131 | + $post = $posts[$id]; |
|
| 132 | + $post_data = $post->getPostBody(); |
|
| 133 | + $ret[$i]['topic_id'] = $post->getVar('topic_id'); |
|
| 134 | + $ret[$i]['link'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key |
|
| 135 | + $ret[$i]['title'] = $post_data['subject']; |
|
| 136 | + $ret[$i]['time'] = $post_data['date']; |
|
| 137 | + $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']); |
|
| 138 | + $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id'); |
|
| 139 | + $ret[$i]['post_text'] = $post_data['text']; |
|
| 140 | + $ret[$i]['uid'] = $post->getVar('uid'); |
|
| 141 | + $ret[$i]['poster'] = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author']; |
|
| 142 | + ++$i; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - return $ret; |
|
| 145 | + return $ret; |
|
| 146 | 146 | } |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | // MENU handler |
| 75 | 75 | /* You could remove anyone by commenting out in order to disable it */ |
| 76 | 76 | $customConfig['valid_menumodes'] = [ |
| 77 | - 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 77 | + 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 78 | 78 | //1 => _MD_NEWBB_MENU_CLICK, // for "click to expand" |
| 79 | 79 | //2 => _MD_NEWBB_MENU_HOVER // for "mouse hover to expand" |
| 80 | 80 | ]; |
@@ -74,9 +74,9 @@ |
||
| 74 | 74 | // MENU handler |
| 75 | 75 | /* You could remove anyone by commenting out in order to disable it */ |
| 76 | 76 | $customConfig['valid_menumodes'] = [ |
| 77 | - 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 78 | - //1 => _MD_NEWBB_MENU_CLICK, // for "click to expand" |
|
| 79 | - //2 => _MD_NEWBB_MENU_HOVER // for "mouse hover to expand" |
|
| 77 | + 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 78 | + //1 => _MD_NEWBB_MENU_CLICK, // for "click to expand" |
|
| 79 | + //2 => _MD_NEWBB_MENU_HOVER // for "mouse hover to expand" |
|
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | // view latest edit |
@@ -72,8 +72,8 @@ |
||
| 72 | 72 | // MENU handler |
| 73 | 73 | /* You could remove anyone by commenting out in order to disable it */ |
| 74 | 74 | $valid_menumodes = [ |
| 75 | - 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 76 | - 1 => _MD_NEWBB_MENU_CLICK, // for 'click to expand' |
|
| 75 | + 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 76 | + 1 => _MD_NEWBB_MENU_CLICK, // for 'click to expand' |
|
| 77 | 77 | 2 => _MD_NEWBB_MENU_HOVER // for 'mouse hover to expand' |
| 78 | 78 | ]; |
| 79 | 79 | |
@@ -72,9 +72,9 @@ |
||
| 72 | 72 | // MENU handler |
| 73 | 73 | /* You could remove anyone by commenting out in order to disable it */ |
| 74 | 74 | $valid_menumodes = [ |
| 75 | - 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 76 | - 1 => _MD_NEWBB_MENU_CLICK, // for 'click to expand' |
|
| 77 | - 2 => _MD_NEWBB_MENU_HOVER // for 'mouse hover to expand' |
|
| 75 | + 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
| 76 | + 1 => _MD_NEWBB_MENU_CLICK, // for 'click to expand' |
|
| 77 | + 2 => _MD_NEWBB_MENU_HOVER // for 'mouse hover to expand' |
|
| 78 | 78 | ]; |
| 79 | 79 | |
| 80 | 80 | return $customConfig; |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $forumImage['facebook'] = $forumImage['twitter'] = $forumImage['linkedin'] = $forumImage['googleplus'] = $forumImage['stumbleupon'] = $forumImage['friendfeed'] = $forumImage['digg'] = $forumImage['reddit'] = $forumImage['delicious'] = $forumImage['technorati'] = $forumImage['wong'] = $forumImage['anonym'] = $forumImage['more'] = $forumImage['less'] = 'icon'; |
| 49 | 49 | |
| 50 | 50 | for ($i = 1; $i <= 5; ++$i) { |
| 51 | - $forumImage['rate' . $i] = 'icon'; |
|
| 51 | + $forumImage['rate'.$i] = 'icon'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $forumImage['p_delete'] = $forumImage['p_reply'] = $forumImage['p_quote'] = $forumImage['p_edit'] = $forumImage['p_report'] = |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $forumImage['facebook'] = $forumImage['twitter'] = $forumImage['linkedin'] = $forumImage['googleplus'] = $forumImage['stumbleupon'] = $forumImage['friendfeed'] = $forumImage['digg'] = $forumImage['reddit'] = $forumImage['delicious'] = $forumImage['technorati'] = $forumImage['wong'] = $forumImage['anonym'] = $forumImage['more'] = $forumImage['less'] = 'icon'; |
| 49 | 49 | |
| 50 | 50 | for ($i = 1; $i <= 5; ++$i) { |
| 51 | - $forumImage['rate' . $i] = 'icon'; |
|
| 51 | + $forumImage['rate' . $i] = 'icon'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $forumImage['p_delete'] = $forumImage['p_reply'] = $forumImage['p_quote'] = $forumImage['p_edit'] = $forumImage['p_report'] = |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $forumImage['p_bann'] = |
| 63 | 63 | |
| 64 | - 'language'; |
|
| 64 | + 'language'; |
|
| 65 | 65 | |
| 66 | 66 | /* |
| 67 | 67 | $forumImage[''] = $forumImage['blank'] = $forumImage['icon']."blank"; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | global $pathIcon32; |
| 21 | 21 | if (!class_exists('\Xoops', false)) { |
| 22 | - echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "</div>\n"; |
|
| 22 | + echo "<div class='adminfooter'>\n"." <div style='text-align: center;'>\n"." <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n"." </div>\n".' '._AM_MODULEADMIN_ADMIN_FOOTER."\n"."</div>\n"; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | xoops_cp_footer(); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | global $pathIcon32; |
| 21 | 21 | |
| 22 | 22 | if (!class_exists('\Xoops', false)) { |
| 23 | - echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "</div>\n"; |
|
| 23 | + echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "</div>\n"; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | xoops_cp_footer(); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
| 29 | 29 | |
| 30 | 30 | // The forum instanciation |
| 31 | -$form_forum = new \XoopsThemeForm(_AM_NEWBB_EDITTHISFORUM . ' ' . $forumObject->getVar('forum_name'), 'form_forum', xoops_getenv('PHP_SELF')); |
|
| 31 | +$form_forum = new \XoopsThemeForm(_AM_NEWBB_EDITTHISFORUM.' '.$forumObject->getVar('forum_name'), 'form_forum', xoops_getenv('PHP_SELF')); |
|
| 32 | 32 | |
| 33 | 33 | // Forum name |
| 34 | 34 | $form_forum->addElement(new \XoopsFormText(_AM_NEWBB_FORUMNAME, 'forum_name', 50, 80, $forumObject->getVar('forum_name', 'E')), true); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $perm_checkbox = new \XoopsFormCheckBox('', 'perm_template', $forumObject->isNew()); |
| 66 | 66 | $perm_checkbox->addOption(1, _AM_NEWBB_PERM_TEMPLATEAPP); |
| 67 | 67 | $perm_tray->addElement($perm_checkbox); |
| 68 | -$perm_tray->addElement(new \XoopsFormLabel('', '<a href="admin_permissions.php?action=template" rel="external" title="">' . _AM_NEWBB_PERM_TEMPLATE . '</a>')); |
|
| 68 | +$perm_tray->addElement(new \XoopsFormLabel('', '<a href="admin_permissions.php?action=template" rel="external" title="">'._AM_NEWBB_PERM_TEMPLATE.'</a>')); |
|
| 69 | 69 | $form_forum->addElement($perm_tray); |
| 70 | 70 | |
| 71 | 71 | $form_forum->addElement(new \XoopsFormHidden('forum', $forumObject->getVar('forum_id'))); |
@@ -19,9 +19,9 @@ |
||
| 19 | 19 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
| 20 | 20 | |
| 21 | 21 | if (!is_object($forumObject)) { |
| 22 | - xoops_error('forum object IS null'); |
|
| 22 | + xoops_error('forum object IS null'); |
|
| 23 | 23 | |
| 24 | - return; |
|
| 24 | + return; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | require_once $GLOBALS['xoops']->path('class/xoopstree.php'); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
| 13 | 13 | require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); |
| 14 | -require_once __DIR__ . '/functions.session.php'; |
|
| 14 | +require_once __DIR__.'/functions.session.php'; |
|
| 15 | 15 | |
| 16 | 16 | // NewBB cookie structure |
| 17 | 17 | /* NewBB cookie storage |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $forumCookie['path'] = '/'; |
| 34 | 34 | $forumCookie['secure'] = false; |
| 35 | 35 | $forumCookie['expire'] = time() + 3600 * 24 * 30; // one month |
| 36 | -$forumCookie['prefix'] = 'newbb_' . (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : '0IP' . \Xmf\IPAddress::fromRequest()->asReadable()); // irmtfan IP for anons - use $GLOBALS["xoopsUser"] |
|
| 36 | +$forumCookie['prefix'] = 'newbb_'.(is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : '0IP'.\Xmf\IPAddress::fromRequest()->asReadable()); // irmtfan IP for anons - use $GLOBALS["xoopsUser"] |
|
| 37 | 37 | |
| 38 | 38 | // set LastVisitTemp cookie, which only gets the time from the LastVisit cookie if it does not exist yet |
| 39 | 39 | // otherwise, it gets the time from the LastVisitTemp cookie |
@@ -47,5 +47,5 @@ |
||
| 47 | 47 | |
| 48 | 48 | // include customized variables |
| 49 | 49 | if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname', 'n')) { |
| 50 | - $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig(); |
|
| 50 | + $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig(); |
|
| 51 | 51 | } |
@@ -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 | } |