Changeset 702 for trunk/forum/includes/functions_posting.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/functions_posting.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_posting.php 9166 2008-12-03 16:40:53Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 25 25 global $phpEx, $phpbb_root_path; 26 26 27 $start = request_var('start', 0); 28 27 29 if ($mode == 'window') 28 30 { … … 45 47 page_header($user->lang['SMILIES']); 46 48 49 $sql = 'SELECT COUNT(smiley_id) AS item_count 50 FROM ' . SMILIES_TABLE . ' 51 GROUP BY smiley_url'; 52 $result = $db->sql_query($sql, 3600); 53 54 $smiley_count = 0; 55 while ($row = $db->sql_fetchrow($result)) 56 { 57 ++$smiley_count; 58 } 59 $db->sql_freeresult($result); 60 47 61 $template->set_filenames(array( 48 62 'body' => 'posting_smilies.html') 63 ); 64 65 $template->assign_var('PAGINATION', 66 generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id), 67 $smiley_count, $config['smilies_per_page'], $start, true) 49 68 ); 50 69 } … … 65 84 } 66 85 67 $last_url = ''; 68 69 $sql = 'SELECT * 70 FROM ' . SMILIES_TABLE . 71 (($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . ' 72 ORDER BY smiley_order'; 73 $result = $db->sql_query($sql, 3600); 86 if ($mode == 'window') 87 { 88 $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height 89 FROM ' . SMILIES_TABLE . ' 90 GROUP BY smiley_url, smiley_width, smiley_height 91 ORDER BY MIN(smiley_order)'; 92 $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600); 93 } 94 else 95 { 96 $sql = 'SELECT * 97 FROM ' . SMILIES_TABLE . ' 98 WHERE display_on_posting = 1 99 ORDER BY smiley_order'; 100 $result = $db->sql_query($sql, 3600); 101 } 74 102 75 103 $smilies = array(); … … 85 113 if (sizeof($smilies)) 86 114 { 115 $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; 116 87 117 foreach ($smilies as $row) 88 118 { … … 90 120 'SMILEY_CODE' => $row['code'], 91 121 'A_SMILEY_CODE' => addslashes($row['code']), 92 'SMILEY_IMG' => $ phpbb_root_path . $config['smilies_path'] . '/' . $row['smiley_url'],122 'SMILEY_IMG' => $root_path . $config['smilies_path'] . '/' . $row['smiley_url'], 93 123 'SMILEY_WIDTH' => $row['smiley_width'], 94 124 'SMILEY_HEIGHT' => $row['smiley_height'], … … 615 645 616 646 // Do not create a thumbnail if the resulting width/height is bigger than the original one 617 if ($new_width > $width && $new_height >$height)647 if ($new_width >= $width && $new_height >= $height) 618 648 { 619 649 return false; … … 630 660 } 631 661 632 @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 - antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $destination) . '"');662 @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"'); 633 663 634 664 if (file_exists($destination)) … … 657 687 658 688 case IMG_JPG: 689 @ini_set('gd.jpeg_ignore_warning', 1); 659 690 $image = @imagecreatefromjpeg($source); 660 691 break; … … 667 698 $image = @imagecreatefromwbmp($source); 668 699 break; 700 } 701 702 if (empty($image)) 703 { 704 return false; 669 705 } 670 706 … … 752 788 foreach ($attachment_data as $i => $attachment) 753 789 { 754 $s_inline_attachment_options .= '<option value="' . $i . '">' . basename($attachment['real_filename']) . '</option>';790 $s_inline_attachment_options .= '<option value="' . $i . '">' . utf8_basename($attachment['real_filename']) . '</option>'; 755 791 } 756 792 … … 786 822 { 787 823 $hidden = ''; 788 $attach_row['real_filename'] = basename($attach_row['real_filename']);824 $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']); 789 825 790 826 foreach ($attach_row as $key => $value) … … 796 832 797 833 $template->assign_block_vars('attach_row', array( 798 'FILENAME' => basename($attach_row['real_filename']),799 'A_FILENAME' => addslashes( basename($attach_row['real_filename'])),834 'FILENAME' => utf8_basename($attach_row['real_filename']), 835 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), 800 836 'FILE_COMMENT' => $attach_row['attach_comment'], 801 837 'ATTACH_ID' => $attach_row['attach_id'], … … 819 855 * Load Drafts 820 856 */ 821 function load_drafts($topic_id = 0, $forum_id = 0, $id = 0 )857 function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $msg_id = 0) 822 858 { 823 859 global $user, $db, $template, $auth; … … 912 948 // Either display as PM draft if forum_id and topic_id are empty or if access to the forums has been denied afterwards... 913 949 $link_pm = true; 914 $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" );950 $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d={$draft['draft_id']}" . (($pm_action) ? "&action=$pm_action" : '') . (($msg_id) ? "&p=$msg_id" : '')); 915 951 } 916 952 … … 945 981 " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . ' 946 982 ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' 983 ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' 947 984 ORDER BY p.post_time '; 948 985 $sql .= ($mode == 'post_review') ? 'ASC' : 'DESC'; … … 963 1000 } 964 1001 1002 // Handle 'post_review_edit' like 'post_review' from now on 1003 if ($mode == 'post_review_edit') 1004 { 1005 $mode = 'post_review'; 1006 } 1007 965 1008 $sql = $db->sql_build_query('SELECT', array( 966 'SELECT' => 'u.username, u.user_id, u.user_colour, p.* ',1009 'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe', 967 1010 968 1011 'FROM' => array( 969 1012 USERS_TABLE => 'u', 970 1013 POSTS_TABLE => 'p', 1014 ), 1015 1016 'LEFT_JOIN' => array( 1017 array( 1018 'FROM' => array(ZEBRA_TABLE => 'z'), 1019 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id' 1020 ) 971 1021 ), 972 1022 … … 1061 1111 $post_subject = censor_text($post_subject); 1062 1112 1113 $post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id']; 1114 $u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}"); 1115 1063 1116 $template->assign_block_vars($mode . '_row', array( 1064 1117 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), … … 1068 1121 1069 1122 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 1123 'S_FRIEND' => ($row['friend']) ? true : false, 1124 'S_IGNORE_POST' => ($row['foe']) ? true : false, 1125 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"dE('{$post_anchor}', 1); return false;\">", '</a>') : '', 1070 1126 1071 1127 'POST_SUBJECT' => $post_subject, … … 1114 1170 if (!$topic_notification && !$forum_notification) 1115 1171 { 1116 trigger_error(' WRONG_NOTIFICATION_MODE');1172 trigger_error('NO_MODE'); 1117 1173 } 1118 1174 … … 1502 1558 } 1503 1559 1560 if (($post_mode == 'delete') || ($post_mode == 'delete_last_post') || ($post_mode == 'delete_first_post')) 1561 { 1562 $sql = 'SELECT 1 AS has_attachments 1563 FROM ' . ATTACHMENTS_TABLE . ' 1564 WHERE topic_id = ' . $topic_id; 1565 $result = $db->sql_query_limit($sql, 1); 1566 $has_attachments = (int) $db->sql_fetchfield('has_attachments'); 1567 $db->sql_freeresult($result); 1568 1569 if (!$has_attachments) 1570 { 1571 $sql_data[TOPICS_TABLE] .= ', topic_attachment = 0'; 1572 } 1573 } 1574 1504 1575 // $sql_data[USERS_TABLE] = ($data['post_postcount']) ? 'user_posts = user_posts - 1' : ''; 1505 1576 … … 1553 1624 /** 1554 1625 * Submit Post 1626 * @todo Split up and create lightweight, simple API for this. 1555 1627 */ 1556 function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true )1628 function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) 1557 1629 { 1558 1630 global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path; … … 1606 1678 1607 1679 // This variable indicates if the user is able to post or put into the queue - it is used later for all code decisions regarding approval 1680 // The variable name should be $post_approved, because it indicates if the post is approved or not 1608 1681 $post_approval = 1; 1609 1682 1610 // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. 1611 if ((($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) 1612 { 1683 // Check the permissions for post approval. Moderators are not affected. 1684 if (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) 1685 { 1686 // Post not approved, but in queue 1613 1687 $post_approval = 0; 1688 } 1689 1690 // Mods are able to force approved/unapproved posts. True means the post is approved, false the post is unapproved 1691 if (isset($data['force_approved_state'])) 1692 { 1693 $post_approval = ($data['force_approved_state']) ? 1 : 0; 1614 1694 } 1615 1695 … … 1726 1806 'topic_poster' => (int) $user->data['user_id'], 1727 1807 'topic_time' => $current_time, 1808 'topic_last_view_time' => $current_time, 1728 1809 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], 1729 1810 'icon_id' => $data['icon_id'], … … 1739 1820 if (isset($poll['poll_options']) && !empty($poll['poll_options'])) 1740 1821 { 1822 $poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time; 1823 $poll_length = $poll['poll_length'] * 86400; 1824 if ($poll_length < 0) 1825 { 1826 $poll_start = $poll_start + $poll_length; 1827 if ($poll_start < 0) 1828 { 1829 $poll_start = 0; 1830 } 1831 $poll_length = 1; 1832 } 1833 1741 1834 $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( 1742 1835 'poll_title' => $poll['poll_title'], 1743 'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time,1836 'poll_start' => $poll_start, 1744 1837 'poll_max_options' => $poll['poll_max_options'], 1745 'poll_length' => ($poll['poll_length'] * 86400),1838 'poll_length' => $poll_length, 1746 1839 'poll_vote_change' => $poll['poll_vote_change']) 1747 1840 ); … … 1761 1854 1762 1855 case 'reply': 1763 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . (($post_approval) ? ', topic_replies = topic_replies + 1' : '') . ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : ''); 1856 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_view_time = ' . $current_time . ', 1857 topic_replies_real = topic_replies_real + 1, 1858 topic_bumped = 0, 1859 topic_bumper = 0' . 1860 (($post_approval) ? ', topic_replies = topic_replies + 1' : '') . 1861 ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : ''); 1862 1764 1863 $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ', user_posts = user_posts + 1' : ''); 1765 1864 … … 1772 1871 case 'edit_topic': 1773 1872 case 'edit_first_post': 1873 if (isset($poll['poll_options']) && !empty($poll['poll_options'])) 1874 { 1875 $poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time; 1876 $poll_length = $poll['poll_length'] * 86400; 1877 if ($poll_length < 0) 1878 { 1879 $poll_start = $poll_start + $poll_length; 1880 if ($poll_start < 0) 1881 { 1882 $poll_start = 0; 1883 } 1884 $poll_length = 1; 1885 } 1886 } 1774 1887 1775 1888 $sql_data[TOPICS_TABLE]['sql'] = array( … … 1782 1895 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, 1783 1896 'poll_title' => (isset($poll['poll_options'])) ? $poll['poll_title'] : '', 1784 'poll_start' => (isset($poll['poll_options'])) ? (($poll['poll_start']) ? $poll['poll_start'] : $current_time): 0,1897 'poll_start' => (isset($poll['poll_options'])) ? $poll_start : 0, 1785 1898 'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1, 1786 'poll_length' => (isset($poll['poll_options'])) ? ($poll['poll_length'] * 86400): 0,1899 'poll_length' => (isset($poll['poll_options'])) ? $poll_length : 0, 1787 1900 'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0, 1901 'topic_last_view_time' => $current_time, 1788 1902 1789 1903 'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0), … … 1811 1925 $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1); 1812 1926 1813 set_config ('num_topics', $config['num_topics'] -1, true);1814 set_config ('num_posts', $config['num_posts'] - ($topic_row['topic_replies'] +1), true);1927 set_config_count('num_topics', -1, true); 1928 set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true); 1815 1929 1816 1930 // Only decrement this post, since this is the one non-approved now … … 1829 1943 if (!$post_approval && $data['post_approved']) 1830 1944 { 1831 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1 ';1945 $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time; 1832 1946 $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1'; 1833 1947 1834 set_config ('num_posts', $config['num_posts'] -1, true);1948 set_config_count('num_posts', -1, true); 1835 1949 1836 1950 if ($auth->acl_get('f_postcount', $data['forum_id'])) … … 2073 2187 { 2074 2188 // insert attachment into db 2075 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))2189 if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) 2076 2190 { 2077 2191 continue; … … 2099 2213 if ($space_taken && $files_added) 2100 2214 { 2101 set_config ('upload_dir_size', $config['upload_dir_size'] +$space_taken, true);2102 set_config ('num_files', $config['num_files'] +$files_added, true);2215 set_config_count('upload_dir_size', $space_taken, true); 2216 set_config_count('num_files', $files_added, true); 2103 2217 } 2104 2218 } … … 2333 2447 if ($post_mode == 'post') 2334 2448 { 2335 set_config ('num_topics', $config['num_topics'] +1, true);2336 set_config ('num_posts', $config['num_posts'] +1, true);2449 set_config_count('num_topics', 1, true); 2450 set_config_count('num_posts', 1, true); 2337 2451 } 2338 2452 2339 2453 if ($post_mode == 'reply') 2340 2454 { 2341 set_config ('num_posts', $config['num_posts'] +1, true);2455 set_config_count('num_posts', 1, true); 2342 2456 } 2343 2457 } … … 2377 2491 2378 2492 // Index message contents 2379 if ($update_ message&& $data['enable_indexing'])2493 if ($update_search_index && $data['enable_indexing']) 2380 2494 { 2381 2495 // Select the search method and do some additional checks to ensure it can actually be utilised … … 2412 2526 $db->sql_query($sql); 2413 2527 } 2414 else if ( $data['notify_set'] && !$data['notify'])2528 else if (($config['email_enable'] || $config['jab_enable']) && $data['notify_set'] && !$data['notify']) 2415 2529 { 2416 2530 $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' … … 2429 2543 // Mark this topic as read 2430 2544 // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) 2431 markread('topic', $data['forum_id'], $data['topic_id'], time());2545 markread('topic', (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $data['topic_id'], time()); 2432 2546 2433 2547 // … … 2437 2551 FROM ' . FORUMS_TRACK_TABLE . ' 2438 2552 WHERE user_id = ' . $user->data['user_id'] . ' 2439 AND forum_id = ' . $data['forum_id'];2553 AND forum_id = ' . (($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']); 2440 2554 $result = $db->sql_query($sql); 2441 2555 $f_mark_time = (int) $db->sql_fetchfield('mark_time'); … … 2450 2564 { 2451 2565 // Update forum info 2452 $sql = 'SELECT forum_last_post_time 2453 FROM ' . FORUMS_TABLE . ' 2454 WHERE forum_id = ' . $data['forum_id']; 2566 if ($topic_type == POST_GLOBAL) 2567 { 2568 $sql = 'SELECT MAX(topic_last_post_time) as forum_last_post_time 2569 FROM ' . TOPICS_TABLE . ' 2570 WHERE forum_id = 0'; 2571 } 2572 else 2573 { 2574 $sql = 'SELECT forum_last_post_time 2575 FROM ' . FORUMS_TABLE . ' 2576 WHERE forum_id = ' . $data['forum_id']; 2577 } 2455 2578 $result = $db->sql_query($sql); 2456 2579 $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); 2457 2580 $db->sql_freeresult($result); 2458 2581 2459 update_forum_tracking_info( $data['forum_id'], $forum_last_post_time, $f_mark_time, false);2582 update_forum_tracking_info((($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']), $forum_last_post_time, $f_mark_time, false); 2460 2583 } 2461 2584
Note:
See TracChangeset
for help on using the changeset viewer.