Просмотр файла book.php

Размер файла: 27.74Kb
  1. <?php
  2.  
  3. define('IN_PHPBB', true);
  4. $phpbb_root_path = './';
  5. require_once($phpbb_root_path . 'extension.inc');
  6. require_once($phpbb_root_path . 'common.'.$phpEx);
  7. require_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
  8.  
  9. define ('NUM_SHOUT', 20);
  10. //
  11. // Start session management
  12. //
  13. $userdata = session_pagestart($user_ip, PAGE_SHOUTBOX_MAX);
  14. init_userprefs($userdata);
  15. //
  16. // End session management
  17. //
  18. $page_title = 'Гостевая книга';
  19.  
  20. //
  21. // Start auth check
  22. //
  23. switch ($userdata['user_level'])
  24. {
  25. //Costomice this, if you need other permission settings
  26. // please also make same changes to other shoutbox php files
  27. case ADMIN :
  28. case MOD : $is_auth['auth_mod'] = 1;
  29. default:
  30. $is_auth['auth_read'] = 1;
  31. $is_auth['auth_view'] = 1;
  32. if ($userdata['user_id']==ANONYMOUS)
  33. {
  34. $is_auth['auth_delete'] = 0;
  35. $is_auth['auth_post'] = 1;
  36. } else
  37. {
  38. $is_auth['auth_delete'] = 1;
  39. $is_auth['auth_post'] = 1;
  40. }
  41. }
  42.  
  43. if( !$is_auth['auth_read'] )
  44. {
  45. message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
  46. }
  47.  
  48. $forum_id=PAGE_SHOUTBOX_MAX;
  49. $refresh = (isset($HTTP_POST_VARS['auto_refresh']) || isset($HTTP_POST_VARS['refresh'])) ? 1 : 0;
  50. $preview = (isset($HTTP_POST_VARS['preview'])) ? 1 : 0;
  51. $submit = (isset($HTTP_POST_VARS['shout']) && isset($HTTP_POST_VARS['message'])) ? 1 : 0;
  52. if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
  53. {
  54. $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
  55. }
  56. else
  57. {
  58. $mode = '';
  59. }
  60.  
  61. //
  62. // Set toggles for various options
  63. //
  64. if ( !$board_config['allow_html'] )
  65. {
  66. $html_on = 0;
  67. }
  68. else
  69. {
  70. $html_on = ( $submit || $refresh || preview) ? ( ( !empty($HTTP_POST_VARS['disable_html']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_html'] : $userdata['user_allowhtml'] );
  71. }
  72. if ( !$board_config['allow_bbcode'] )
  73. {
  74. $bbcode_on = 0;
  75. }
  76. else
  77. {
  78. $bbcode_on = ( $submit || $refresh || preview) ? ( ( !empty($HTTP_POST_VARS['disable_bbcode']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_bbcode'] : $userdata['user_allowbbcode'] );
  79. }
  80.  
  81. if ( !$board_config['allow_smilies'] )
  82. {
  83. $smilies_on = 0;
  84. }
  85. else
  86. {
  87. $smilies_on = ( $submit || $refresh || preview) ? ( ( !empty($HTTP_POST_VARS['disable_smilies']) ) ? 0 : TRUE ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] );
  88. }
  89. if( !$userdata['session_logged_in'] || ( $mode == 'editpost' && $post_info['poster_id'] == ANONYMOUS ) )
  90. {
  91. $template->assign_block_vars('switch_username_select', array());
  92. }
  93. $username = ( !empty($HTTP_POST_VARS['username']) ) ? $HTTP_POST_VARS['username'] : '';
  94. // Check username
  95. if ( !empty($username) )
  96. {
  97. $username = htmlspecialchars(trim(strip_tags($username)));
  98. if ( !$userdata['session_logged_in'])
  99. {
  100. require_once($phpbb_root_path . 'includes/functions_validate.'.$phpEx);
  101. $result = validate_username($username);
  102. if ( $result['error'] )
  103. {
  104. $error = true;
  105. $error_msg .= ( !empty($error_msg) ) ? '<br />' . $result['error_msg'] : $result['error_msg'];
  106. }
  107. }
  108. }
  109.  
  110. if ($refresh || $preview)
  111. {
  112. $message = ( !empty($HTTP_POST_VARS['message']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['message']))) : '';
  113. if (!empty($message))
  114. {
  115. if ($preview)
  116. {
  117. require_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
  118. $orig_word = array();
  119. $replacement_word = array();
  120. obtain_word_list($orig_word, $replacement_word);
  121. $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
  122. $preview_message = stripslashes(prepare_message(addslashes(unprepare_message($message)), $html_on, $bbcode_on, $smilies_on, $bbcode_uid));
  123.  
  124. if( $bbcode_on )
  125. {
  126. $preview_message = bbencode_second_pass($preview_message, $bbcode_uid);
  127. }
  128. if( !empty($orig_word) )
  129. {
  130. $preview_message = ( !empty($preview_message) ) ? preg_replace($orig_word, $replacement_word, $preview_message) : '';
  131. }
  132. $preview_message = make_clickable($preview_message);
  133. if( $smilies_on )
  134. {
  135. $preview_message = smilies_pass($preview_message);
  136. }
  137. $preview_message = str_replace("\n", '<br />', $preview_message);
  138. $template->set_filenames(array(
  139. 'preview' => 'posting_preview.tpl')
  140. );
  141. $template->assign_vars(array(
  142. 'USERNAME' => $username,
  143. 'POST_DATE' => create_date($board_config['default_dateformat'], time(), $board_config['board_timezone']),
  144. 'MESSAGE' => $preview_message,
  145. 'L_POSTED' => $lang['Posted'],
  146. 'L_PREVIEW' => $lang['Preview'])
  147. );
  148. $template->assign_var_from_handle('POST_PREVIEW_BOX', 'preview');
  149. }
  150. $template->assign_var('MESSAGE',$message);
  151. }
  152. } else
  153. if ($submit || isset($HTTP_POST_VARS['message']))
  154. {
  155. $current_time = time();
  156. //
  157. // Flood control
  158. //
  159. $where_sql = ( $userdata['user_id'] == ANONYMOUS ) ? "shout_ip = '$user_ip'" : 'shout_user_id = ' . $userdata['user_id'];
  160. $sql = "SELECT MAX(shout_session_time) AS last_post_time
  161. FROM " . SHOUTBOX_TABLE . "
  162. WHERE $where_sql";
  163. if ( $result = $db->sql_query($sql) )
  164. {
  165. if ( $row = $db->sql_fetchrow($result) )
  166. {
  167. if ( $row['last_post_time'] > 0 && ( $current_time - $row['last_post_time'] ) < $board_config['flood_interval'] )
  168. {
  169. $error = true;
  170. $error_msg .= ( !empty($error_msg) ) ? '<br /><div style="text-align:center">' . $lang['Flood_Error'] : $lang['Flood_Error'] .' fgf';
  171. }
  172. }
  173. }
  174.  
  175. $message = (isset($HTTP_POST_VARS['message'])) ? trim($HTTP_POST_VARS['message']) : '';
  176. // insert shout !
  177. if (!empty($message) && $is_auth['auth_post'] && !$error)
  178. {
  179. require_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
  180. $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
  181. $message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
  182. $sql = "INSERT INTO " . SHOUTBOX_TABLE. " (shout_text, shout_session_time, shout_user_id, shout_ip, shout_username, shout_bbcode_uid,enable_bbcode,enable_html,enable_smilies)
  183. VALUES ('$message', '".time()."', '".$userdata['user_id']."', '$user_ip', '".$username."', '".$bbcode_uid."',$bbcode_on,$html_on,$smilies_on)";
  184. if (!$result = $db->sql_query($sql))
  185. {
  186. message_die(GENERAL_ERROR, 'Error inserting shout.', '', __LINE__, __FILE__, $sql);
  187. }
  188. // auto prune
  189. if ($board_config['prune_shouts'])
  190. {
  191. $sql = "DELETE FROM " . SHOUTBOX_TABLE. " WHERE shout_session_time<=".(time()-86400*$board_config['prune_shouts']);
  192. if (!$result = $db->sql_query($sql))
  193. {
  194. message_die(GENERAL_ERROR, 'Error autoprune shouts.', '', __LINE__, __FILE__, $sql);
  195. }
  196. }
  197. }
  198. } else
  199. if ($mode=='delete' || $mode=='censor')
  200. {
  201. // make shout inavtive
  202. if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
  203. {
  204. $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
  205. }
  206. else
  207. {
  208. message_die(GENERAL_ERROR, 'Error no shout id specifyed for delete/censor.', '', __LINE__, __FILE__);
  209. }
  210. $sql = "SELECT s.shout_user_id, shout_ip FROM " . SHOUTBOX_TABLE . " s WHERE s.shout_id='$post_id'";
  211. if ( !($result = $db->sql_query($sql)) )
  212. {
  213. message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
  214. }
  215. $shout_identifyer = $db->sql_fetchrow($result);
  216. $user_id = $shout_identifyer['shout_user_id'];
  217.  
  218. if (
  219. ($userdata['user_id'] != ANONYMOUS || ( $userdata['user_id'] == ANONYMOUS && $userdata['session_ip'] == $shout_identifyer['shout_ip'])) &&
  220. (($userdata['user_id'] == $user_id && $is_auth['auth_delete']) || $is_auth['auth_mod']) && $mode=='censor')
  221. {
  222. $sql = "UPDATE ".SHOUTBOX_TABLE." SET shout_active='".$userdata['user_id']."' WHERE shout_id='$post_id'";
  223. if (!$result = $db->sql_query($sql))
  224. {
  225. message_die(GENERAL_ERROR, 'Error censor shout.', '', __LINE__, __FILE__, $sql);
  226. }
  227. } else
  228. if ( $is_auth['auth_mod'] && $mode=='delete')
  229. {
  230. $sql = "DELETE FROM ".SHOUTBOX_TABLE." WHERE shout_id='$post_id'";
  231. if (!$result = $db->sql_query($sql))
  232. {
  233. message_die(GENERAL_ERROR, 'Error removing shout.', '', __LINE__, __FILE__, $sql);
  234. }
  235. } else
  236. message_die(GENERAL_MESSAGE, 'Not allowed.', '', __LINE__, __FILE__);
  237. } else
  238. if ($mode=='ip')
  239. {
  240. // show the ip
  241. if ( !$is_auth['auth_mod'])
  242. {
  243. message_die(GENERAL_MESSAGE, 'Not allowed.', '', __LINE__, __FILE__);
  244. }
  245. if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
  246. {
  247. $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
  248. }
  249. else
  250. {
  251. message_die(GENERAL_ERROR, 'Error no shout id specifyed for show ip', '', __LINE__, __FILE__);
  252. }
  253. $sql = "SELECT s.shout_user_id, shout_username, shout_ip FROM " . SHOUTBOX_TABLE . " s WHERE s.shout_id='$post_id'";
  254. if ( !($result = $db->sql_query($sql)) )
  255. {
  256. message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
  257. }
  258. $shout_identifyer = $db->sql_fetchrow($result);
  259. $poster_id = $shout_identifyer['shout_user_id'];
  260. $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : "";
  261.  
  262. $ip_this_post = decode_ip($shout_identifyer['shout_ip']);
  263. $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? gethostbyaddr($ip_this_post) : $ip_this_post;
  264. require_once($phpbb_root_path . 'includes/page_header.'.$phpEx);
  265.  
  266. //
  267. // Set template files
  268. //
  269. $template->set_filenames(array(
  270. 'viewip' => 'modcp_viewip.tpl')
  271. );
  272. $template->assign_vars(array(
  273. 'L_IP_INFO' => $lang['IP_info'],
  274. 'L_THIS_POST_IP' => $lang['This_posts_IP'],
  275. 'L_OTHER_IPS' => $lang['Other_IP_this_user'],
  276. 'L_OTHER_USERS' => $lang['Users_this_IP'],
  277. 'L_LOOKUP_IP' => $lang['Lookup_IP'],
  278. 'L_SEARCH' => $lang['Search'],
  279. 'SEARCH_IMG' => $images['icon_search'],
  280. 'IP' => $ip_this_post,
  281. 'U_LOOKUP_IP' => append_sid("book.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;rdns=" . $ip_this_post))
  282. );
  283.  
  284. //
  285. // Get other IP's this user has posted under
  286. //
  287. $sql = "SELECT shout_ip, COUNT(*) AS postings
  288. FROM " . SHOUTBOX_TABLE . "
  289. WHERE shout_user_id = $poster_id
  290. GROUP BY shout_ip
  291. ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
  292. if ( !($result = $db->sql_query($sql)) )
  293. {
  294. message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
  295. }
  296. if ( $row = $db->sql_fetchrow($result) )
  297. {
  298. $i = 0;
  299. do
  300. {
  301. if ( $row['shout_ip'] == $post_row['shout_ip'] )
  302. {
  303. $template->assign_vars(array(
  304. 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ))
  305. );
  306. continue;
  307. }
  308.  
  309. $ip = decode_ip($row['shout_ip']);
  310. $ip = ( $rdns_ip_num == $row['shout_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
  311.  
  312. $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
  313. $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
  314.  
  315. $template->assign_block_vars('iprow', array(
  316. 'ROW_COLOR' => '#' . $row_color,
  317. 'ROW_CLASS' => $row_class,
  318. 'IP' => $ip,
  319. 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
  320.  
  321. 'U_LOOKUP_IP' => append_sid("book.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;rdns=" . $row['shout_ip']))
  322. );
  323.  
  324. $i++;
  325. }
  326. while ( $row = $db->sql_fetchrow($result) );
  327. }
  328.  
  329. //
  330. // Get other users who've posted under this IP
  331. //
  332. $sql = "SELECT u.user_id, u.username, COUNT(*) as postings
  333. FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p
  334. WHERE p.poster_id = u.user_id
  335. AND p.poster_ip = '" . $shout_identifyer['shout_ip'] . "'
  336. GROUP BY u.user_id, u.username
  337. ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
  338.  
  339. if ( !($result = $db->sql_query($sql)) )
  340. {
  341. message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
  342. }
  343.  
  344. if ( $row = $db->sql_fetchrow($result) )
  345. {
  346. $i = 0;
  347. do
  348. {
  349. $id = $row['user_id'];
  350. $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
  351. $shout_username = ( $id == ANONYMOUS && $row['username'] == '' ) ? $lang['Guest'] : $row['username'];
  352.  
  353. $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
  354. $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
  355.  
  356. $template->assign_block_vars('userrow', array(
  357. 'ROW_COLOR' => '#' . $row_color,
  358. 'ROW_CLASS' => $row_class,
  359. 'SHOUT_USERNAME' => $shout_username,
  360. 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
  361. 'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $shout_username),
  362.  
  363. 'U_PROFILE' => append_sid("../pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$id"),
  364. 'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($shout_username) . "&amp;showresults=topics"))
  365. );
  366.  
  367. $i++;
  368. }
  369. while ( $row = $db->sql_fetchrow($result) );
  370. }
  371.  
  372.  
  373. $template->pparse('viewip');
  374. require_once($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  375. exit;
  376. }
  377. if( $userdata['user_on_off'] == 1)
  378. {
  379. if ($postrow[$i]['user_session_time'] >= (time()-$board_config['online_time']))
  380. {
  381. if ($postrow[$i]['user_allow_viewonline'])
  382. {
  383. $online_status = '<span style="color: #0fff0f">[On]</span>';
  384. }
  385. else if ( $is_auth['auth_mod'] || $userdata['user_id'] == $poster_id )
  386. {
  387. $online_status = '<span' . $hidden_color . '>' . $lang['Hidden'] . '</span>';
  388. }
  389. else
  390. {
  391. $online_status = '<span style="color: #b40000">[Off]</span>';
  392. }
  393. }
  394. else
  395. {
  396. $online_status = '';
  397. }
  398. } else {
  399. $online_status = '';
  400. }
  401.  
  402. //
  403. // display the defult page
  404. //
  405.  
  406. // see if we need offset
  407. if ((isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['start'])) && !$submit)
  408. {
  409. $start=(isset($HTTP_POST_VARS['start'])) ? intval($HTTP_POST_VARS['start']) : intval($HTTP_GET_VARS['start']);
  410. } else $start=0;
  411.  
  412. require_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
  413. require_once($phpbb_root_path . 'includes/page_header.'.$phpEx);
  414.  
  415. //
  416. // Was a highlight request part of the URI?
  417. //
  418. $highlight_match = $highlight = '';
  419. if (isset($HTTP_GET_VARS['highlight']))
  420. {
  421. // Split words and phrases
  422. $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight'])));
  423.  
  424. for($i = 0; $i < sizeof($words); $i++)
  425. {
  426. if (trim($words[$i]) != '')
  427. {
  428. $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
  429. }
  430. }
  431. unset($words);
  432.  
  433. $highlight = urlencode($HTTP_GET_VARS['highlight']);
  434. $highlight_match = phpbb_rtrim($highlight_match, "\\");
  435. }
  436.  
  437. $sql = "SELECT *
  438. FROM " . RANKS_TABLE . "
  439. ORDER BY rank_special, rank_min";
  440. if ( !($result = $db->sql_query($sql)) )
  441. {
  442. message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
  443. }
  444.  
  445. $ranksrow = array();
  446. while ( $row = $db->sql_fetchrow($result) )
  447. {
  448. $ranksrow[] = $row;
  449. }
  450. $db->sql_freeresult($result);
  451.  
  452. //
  453. // Define censored word matches
  454. //
  455. $orig_word = array();
  456. $replacement_word = array();
  457. obtain_word_list($orig_word, $replacement_word);
  458.  
  459. // get statistics
  460. $sql = "SELECT COUNT(*) as total FROM " . SHOUTBOX_TABLE;
  461. if ( !($result = $db->sql_query($sql)) )
  462. {
  463. message_die(GENERAL_ERROR, 'Could not get shoutbox stat information', '', __LINE__, __FILE__, $sql);
  464. }
  465. $total_shouts = $db->sql_fetchrow($result);
  466. $total_shouts = $total_shouts['total'];
  467. // parse post permission
  468. if ($is_auth['auth_post'])
  469. {
  470. $template->set_filenames(array('body' => 'book_body.tpl'));
  471. } else
  472. {
  473. $template->set_filenames(array('body' => 'book_guest_body.tpl'));
  474. }
  475. // Generate pagination for shoutbox view
  476. $pagination = ( $highlight_match ) ? generate_pagination("book.$phpEx?highlight=".$highlight, $total_shouts, $board_config['posts_per_page'], $start) : generate_pagination("book.$phpEx?dummy=1", $total_shouts, $board_config['posts_per_page'], $start);
  477.  
  478.  
  479.  
  480. //
  481. // Smilies toggle selection
  482. //
  483. if ( $board_config['allow_smilies'] )
  484. {
  485. $smilies_status = $lang['Smilies_are_ON'];
  486. $template->assign_block_vars('switch_smilies_checkbox', array());
  487. }
  488. else
  489. {
  490. $smilies_status = $lang['Smilies_are_OFF'];
  491. }
  492. //
  493. // HTML toggle selection
  494. //
  495. if ( $board_config['allow_html'] )
  496. {
  497. $html_status = $lang['HTML_is_ON'];
  498. $template->assign_block_vars('switch_html_checkbox', array());
  499. }
  500. else
  501. {
  502. $html_status = $lang['HTML_is_OFF'];
  503. }
  504. //
  505. // BBCode toggle selection
  506. //
  507. if ( $board_config['allow_bbcode'] )
  508. {
  509. $bbcode_status = $lang['BBCode_is_ON'];
  510. $template->assign_block_vars('switch_bbcode_checkbox', array());
  511. }
  512. else
  513. {
  514. $bbcode_status = $lang['BBCode_is_OFF'];
  515. }
  516.  
  517.  
  518. //
  519. // display the shoutbox
  520. //
  521. $sql = "SELECT s.*, u.* FROM " . SHOUTBOX_TABLE . " s, ".USERS_TABLE." u
  522. WHERE s.shout_user_id=u.user_id ORDER BY s.shout_session_time DESC LIMIT $start, ".$board_config['posts_per_page'];
  523. if ( !($result = $db->sql_query($sql)) )
  524. {
  525. message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
  526. }
  527. while ($shout_row = $db->sql_fetchrow($result))
  528. {
  529.  
  530. $user_id = $shout_row['shout_user_id'];
  531. $shout_username = ( $user_id == ANONYMOUS ) ? (( $shout_row['shout_username'] == '' ) ? $lang['Guest'] : $shout_row['shout_username'] ) : "<a href='".append_sid("../pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=".$shout_row['shout_user_id'])."'>".$shout_row['username']."</a>" ;
  532.  
  533. $user_profile = append_sid("../pages/profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id");
  534. $user_posts = ( $shout_row['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $shout_row['user_posts'] : '';
  535. $user_from = ( $shout_row['user_from'] && $shout_row['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $shout_row['user_from'] : '';
  536. $user_joined = ( $shout_row['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $shout_row['user_regdate'], $board_config['board_timezone']) : '';
  537. if ( $shout_row['user_avatar_type'] && $shout_row['user_allowavatar'] )
  538. {
  539. switch( $shout_row['user_avatar_type'] )
  540. {
  541. case USER_AVATAR_UPLOAD:
  542. $user_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="../' . $board_config['avatar_path'] . '/' . $shout_row['user_avatar'] . '" alt="" border="0" />' : '';
  543. break;
  544. case USER_AVATAR_REMOTE:
  545. $user_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="../' . $shout_row['user_avatar'] . '" alt="" border="0" />' : '';
  546. break;
  547. case USER_AVATAR_GALLERY:
  548. $user_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="../' . $board_config['avatar_gallery_path'] . '/' . $shout_row['user_avatar'] . '" alt="" border="0" />' : '';
  549. break;
  550. }
  551. $user_avatar = ($shout_row['user_avatar_url']) ? '<a href="'.$shout_row['user_avatar_url'].'">'.$user_avatar.'</a>' : $user_avatar;
  552.  
  553. } else $user_avatar='<img src="../images/avatars/noavatar.gif" alt="" />';
  554.  
  555. if ($user_id == ANONYMOUS) { $user_avatar='<img src="../images/avatars/guest.gif" alt="" />'; }
  556.  
  557.  
  558.  
  559.  
  560. $shout = (! $shout_row['shout_active']) ? $shout_row['shout_text'] : $lang['Shout_censor'].(($is_auth['auth_mod']) ? '<br/><hr/><br/>'.$shout_row['shout_text'] : '');
  561. $user_sig = ( $shout_row['enable_sig'] && $shout_row['user_sig'] != '' && $board_config['allow_sig'] ) ? $shout_row['user_sig'] : '';
  562. $user_sig_bbcode_uid = $shout_row['user_sig_bbcode_uid'];
  563.  
  564.  
  565. $user_rank = '';
  566. $rank_image = '';
  567. if ( $shout_row['user_rank'])
  568. {
  569. for($j = 0; $j < count($ranksrow); $j++)
  570. {
  571. if ( $shout_row['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
  572. {
  573. $user_rank = ($shout_row['user_id'] != ANONYMOUS) ? $ranksrow[$j]['rank_title'] : '';
  574. $rank_image = ( $ranksrow[$j]['rank_image'] && $shout_row['user_id'] != ANONYMOUS) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $user_rank . '" title="' . $user_rank . '" border="0" /><br />' : '';
  575. }
  576. }
  577. } else
  578. {
  579. for($j = 0; $j < count($ranksrow); $j++)
  580. {
  581. if ( $shout_row['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
  582. {
  583. $user_rank = ($shout_row['user_id'] != ANONYMOUS) ? $ranksrow[$j]['rank_title'] : '';
  584. $rank_image = ( $ranksrow[$j]['rank_image'] && $shout_row['user_id'] != ANONYMOUS) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $user_rank . '" title="' . $user_rank . '" border="0" /><br />' : '';
  585. }
  586. }
  587. }
  588.  
  589. if ( $user_sig != '' )
  590. {
  591. $user_sig = make_clickable($user_sig);
  592. }
  593. $message = make_clickable($message);
  594.  
  595. //
  596. // Highlight active words (primarily for search)
  597. //
  598. if ($highlight_match)
  599. {
  600. $shout = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', addslashes($highlight_match)) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $shout . '<'), 1, -1));
  601. }
  602. //
  603. // Replace naughty words
  604. //
  605. if ( count($orig_word) )
  606. {
  607. if ( $user_sig != '' )
  608. {
  609. $user_sig = preg_replace($orig_word, $replacement_word, $user_sig);
  610. }
  611. }
  612.  
  613. if ( $smilies_on && $shout != '' && $shout_row['enable_smilies'])
  614. {
  615. $shout = smilies_pass($shout);
  616. }
  617. $shout = bbencode_second_pass($shout,$shout_row['shout_bbcode_uid']);
  618. $shout = str_replace("\n", "\n<br />\n", $shout);
  619.  
  620. if ( $is_auth['auth_mod'] && $is_auth['auth_delete'])
  621. {
  622. $temp_url = append_sid("book.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $shout_row['shout_id']);
  623. $ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>';
  624. $ip = '<a href="' . $temp_url . '">' . $lang['View_IP2'] . '</a>';
  625.  
  626. $temp_url = append_sid("book.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $shout_row['shout_id']);
  627. $delshout = '<small>[<a href="' . $temp_url . '">del</a>]</small>';
  628.  
  629. $temp_url = append_sid("book.$phpEx?mode=censor&amp;" . POST_POST_URL . "=" . $shout_row['shout_id']);
  630. $censorshout_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_censor'] . '" alt="' . $lang['Censor'] . '" title="' . $lang['Censor'] . '" border="0" /></a>&nbsp;';
  631. $censorshout = '<a href="' . $temp_url . '">Удалить</a>';
  632. }
  633. else
  634. {
  635. $online_status = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $online_status : '';
  636. $ip_img = '';
  637. $ip = '';
  638.  
  639. if ( ($userdata['user_id'] == $user_id && $is_auth['auth_delete'] ) &&
  640. ($userdata['user_id'] != ANONYMOUS || ( $userdata['user_id'] == ANONYMOUS && $userdata['session_ip'] == $shout_row['shout_ip']))
  641. )
  642.  
  643. {
  644. $temp_url = append_sid("book.$phpEx?mode=censor&amp;" . POST_POST_URL . "=" . $shout_row['shout_id']);
  645. $censorshout_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_censor'] . '" alt="' . $lang['Censor'] . '" title="' . $lang['Censor'] . '" border="0" /></a>&nbsp;';
  646. $censorshout = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
  647. }
  648. else
  649. {
  650. $delshout_img = '';
  651. $delshout = '';
  652. $censorshout_img = '';
  653. $censorshout = '';
  654. }
  655. }
  656.  
  657. $template->assign_block_vars('shoutrow', array(
  658. 'ROW_COLOR' => '#' . $row_color,
  659. 'ROW_CLASS' => $row_class,
  660. 'SHOUT' => $shout,
  661. 'TIME' => create_date($board_config['default_dateformat'], $shout_row['shout_session_time'], $board_config['board_timezone']),
  662. 'SHOUT_USERNAME' => $shout_username,
  663. 'U_VIEW_USER_PROFILE' => $user_profile,
  664. 'USER_RANK' => $user_rank,
  665. 'RANK_IMAGE' => $rank_image,
  666. 'IP_IMG' => $ip_img,
  667. 'IP' => $ip,
  668. 'POSTER_ONLINE_STATUS' => $online_status,
  669. 'OTV'=>$otv,
  670. 'DELETE_IMG' => $delshout_img,
  671. 'DELETE' => $delshout,
  672. 'CENSOR_IMG' => $censorshout_img,
  673. 'CENSOR' => $censorshout,
  674. 'USER_JOINED' => $user_joined,
  675. 'USER_POSTS' => $user_posts,
  676. 'USER_FROM' => $user_from,
  677. 'USER_AVATAR' => $user_avatar,
  678. 'U_SHOUT_ID' => $shout_row['shout_id']
  679. ));
  680. }
  681.  
  682. //
  683. // Show post options
  684. //
  685. if ( $is_auth['auth_post'] )
  686. {
  687. $template->assign_block_vars('switch_auth_post', array());
  688. }
  689. else
  690. {
  691. $template->assign_block_vars('switch_auth_no_post', array());
  692. }
  693. $template->assign_vars(array(
  694. 'USERNAME' => $username,
  695. 'PAGINATION' => $pagination,
  696. 'NUMBER_OF_SHOUTS' => $total_shouts,
  697. 'HTML_STATUS' => $html_status,
  698. 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'),
  699. 'L_SHOUTBOX_LOGIN' => $lang['Login_join'],
  700. 'L_POSTED' => $lang['Posted'],
  701. 'L_AUTHOR' => $lang['Author'],
  702. 'L_MESSAGE' => $lang['Message'],
  703. 'U_SHOUTBOX' => append_sid("book.$phpEx?start=$start"),
  704. 'T_NAME' => $theme['template_name'],
  705. 'T_URL' => "templates/".$theme['template_name'],
  706. 'L_SHOUTBOX' => $lang['Shoutbox'],
  707. 'L_SHOUT_PREVIEW' => $lang['Preview'],
  708. 'L_SHOUT_SUBMIT' => $lang['Go'],
  709. 'L_SHOUT_TEXT' => $lang['Shout_text'],
  710. 'L_SHOUT_REFRESH' => $lang['Shout_refresh'],
  711. 'S_HIDDEN_FIELDS' => $s_hidden_fields,
  712.  
  713. 'SMILIES_STATUS' => $smilies_status,
  714. 'L_BBCODE_B_HELP' => $lang['bbcode_b_help'],
  715. 'L_BBCODE_I_HELP' => $lang['bbcode_i_help'],
  716. 'L_BBCODE_U_HELP' => $lang['bbcode_u_help'],
  717. 'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'],
  718. 'L_BBCODE_C_HELP' => $lang['bbcode_c_help'],
  719. 'L_BBCODE_L_HELP' => $lang['bbcode_l_help'],
  720. 'L_BBCODE_O_HELP' => $lang['bbcode_o_help'],
  721. 'L_BBCODE_P_HELP' => $lang['bbcode_p_help'],
  722. 'L_BBCODE_W_HELP' => $lang['bbcode_w_help'],
  723. 'L_BBCODE_A_HELP' => $lang['bbcode_a_help'],
  724. 'L_BBCODE_S_HELP' => $lang['bbcode_s_help'],
  725. 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
  726. 'L_EMPTY_MESSAGE' => $lang['Empty_message'],
  727.  
  728. 'L_FONT_COLOR' => $lang['Font_color'],
  729. 'L_COLOR_DEFAULT' => $lang['color_default'],
  730. 'L_COLOR_DARK_RED' => $lang['color_dark_red'],
  731. 'L_COLOR_RED' => $lang['color_red'],
  732. 'L_COLOR_ORANGE' => $lang['color_orange'],
  733. 'L_COLOR_BROWN' => $lang['color_brown'],
  734. 'L_COLOR_YELLOW' => $lang['color_yellow'],
  735. 'L_COLOR_GREEN' => $lang['color_green'],
  736. 'L_COLOR_OLIVE' => $lang['color_olive'],
  737. 'L_COLOR_CYAN' => $lang['color_cyan'],
  738. 'L_COLOR_BLUE' => $lang['color_blue'],
  739. 'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'],
  740. 'L_COLOR_INDIGO' => $lang['color_indigo'],
  741. 'L_COLOR_VIOLET' => $lang['color_violet'],
  742. 'L_COLOR_WHITE' => $lang['color_white'],
  743. 'L_COLOR_BLACK' => $lang['color_black'],
  744.  
  745. 'L_FONT_SIZE' => $lang['Font_size'],
  746. 'L_FONT_TINY' => $lang['font_tiny'],
  747. 'L_FONT_SMALL' => $lang['font_small'],
  748. 'L_FONT_NORMAL' => $lang['font_normal'],
  749. 'L_FONT_LARGE' => $lang['font_large'],
  750. 'L_FONT_HUGE' => $lang['font_huge'],
  751. 'L_DISABLE_HTML' => $lang['Disable_HTML_post'],
  752. 'L_DISABLE_BBCODE' => $lang['Disable_BBCode_post'],
  753. 'L_DISABLE_SMILIES' => $lang['Disable_Smilies_post'],
  754.  
  755. 'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'],
  756. 'L_STYLES_TIP' => $lang['Styles_tip'],
  757. 'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '',
  758. 'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '',
  759. 'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : ''
  760.  
  761. ));
  762.  
  763. if( $error_msg != '' )
  764. {
  765. $template->set_filenames(array(
  766. 'reg_header' => 'error_body.tpl')
  767. );
  768. $template->assign_vars(array(
  769. 'ERROR_MESSAGE' => $error_msg)
  770. );
  771. $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
  772. $message = ( !empty($HTTP_POST_VARS['message']) ) ? htmlspecialchars(trim(stripslashes($HTTP_POST_VARS['message']))) : '';
  773. $template->assign_var('MESSAGE',$message);
  774. }
  775.  
  776. $template->pparse('body');
  777.  
  778. //
  779. // Include page tail
  780. //
  781. require_once($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  782.  
  783.  
  784.  
  785. ?>