viewthread.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: viewthread.php 34314 2014-02-20 01:04:24Z nemohou $
  7. */
  8. if(!defined('IN_MOBILE_API')) {
  9. exit('Access Denied');
  10. }
  11. define('IS_WEBVIEW', true);
  12. $_GET['mod'] = 'viewthread';
  13. include_once 'forum.php';
  14. class mobile_api {
  15. function common() {
  16. global $_G;
  17. $_G['setting']['avatarmethod'] = 0;
  18. }
  19. function output() {
  20. extract($GLOBALS);
  21. $_G['forum_thread']['replies'] = $_G['forum_thread']['replies'] >= 0 ? $_G['forum_thread']['replies'] : 0;
  22. if($_G['page'] > @ceil(($_G['forum_thread']['replies'] + 1) / $_G['ppp'])) {
  23. $content = '';
  24. } elseif($postlist) {
  25. if(!function_exists('mobileoem_template')) {
  26. include_once DISCUZ_ROOT.'./source/plugin/mobileoem/discuzcode.func.php';
  27. }
  28. $variable = array();
  29. foreach($GLOBALS['aimgs'] as $pid => $aids) {
  30. foreach($aids as $aid) {
  31. $_url = parse_url($postlist[$pid]['attachments'][$aid]['url']);
  32. $variable['imagelist'][$aid] = (!$postlist[$pid]['attachments'][$aid]['remote'] && !$_url['scheme'] ? $_G['siteurl'] : '').$postlist[$pid]['attachments'][$aid]['url'].$postlist[$pid]['attachments'][$aid]['attachment'];
  33. if(strexists($postlist[$pid]['message'], '[attach]'.$aid.'[/attach]')) {
  34. $postlist[$pid]['message'] = str_replace('[attach]'.$aid.'[/attach]', mobileoem_parseimg($postlist[$pid]['attachments'][$aid]['width'], 0, $variable['imagelist'][$aid]), $postlist[$pid]['message']);
  35. } else {
  36. $postlist[$pid]['message'] .= '<br /><br />'.mobileoem_parseimg($postlist[$pid]['attachments'][$aid]['width'], 0, $variable['imagelist'][$aid]);
  37. }
  38. }
  39. }
  40. foreach($postlist as $pid => $post) {
  41. if($post['attachlist']) {
  42. foreach($post['attachlist'] as $aid) {
  43. $aidencode = packaids($postlist[$pid]['attachments'][$aid]);
  44. $_code = parseurl('/forum.php?mod=attachment&aid='.$aidencode, $postlist[$pid]['attachments'][$aid]['filename'], 0);
  45. if(strexists($postlist[$pid]['message'], '[attach]'.$aid.'[/attach]')) {
  46. $postlist[$pid]['message'] = str_replace('[attach]'.$aid.'[/attach]', $_code, $postlist[$pid]['message']);
  47. } else {
  48. $postlist[$pid]['message'] .= '<br /><br />'.$_code;
  49. }
  50. }
  51. }
  52. $postlist[$pid]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $postlist[$pid]['message']);
  53. }
  54. $get = $_GET;
  55. unset($get['page'], $get['debug']);
  56. $nexturl = http_build_query($get);
  57. include mobileoem_template('forum/viewthread');
  58. if(!empty($_GET['debug'])) {
  59. exit;
  60. }
  61. $content = ob_get_contents();
  62. ob_end_clean();
  63. }
  64. $variable['forumname'] = $forum['name'];
  65. $variable['datatype'] = $_G['page'] == 1 ? 0 : 1;
  66. $variable['webview_page'] = $content;
  67. $variable['ppp'] = $_G['ppp'];
  68. $variable['posts'] = count($postlist);
  69. $variable['page'] = $_G['page'];
  70. if($_G['forum_discuzcode']['passwordauthor']) {
  71. $variable['passwordpid'] = array_keys($_G['forum_discuzcode']['passwordauthor']);
  72. }
  73. mobile_core::result(mobile_core::variable($variable));
  74. }
  75. }
  76. ?>