2001-02-17 08:37:32 +00:00
< ? php
2007-06-09 11:11:20 +00:00
/**
2005-04-09 12:26:45 +00:00
*
* @ package phpBB3
* @ version $Id $
2007-06-09 11:11:20 +00:00
* @ copyright ( c ) 2005 phpBB Group
* @ license http :// opensource . org / licenses / gpl - license . php GNU Public License
2005-04-09 12:26:45 +00:00
*
*/
/**
2006-05-05 17:56:33 +00:00
* @ ignore
2005-04-09 12:26:45 +00:00
*/
2004-01-25 14:30:15 +00:00
define ( 'IN_PHPBB' , true );
2007-07-26 15:51:11 +00:00
$phpbb_root_path = ( defined ( 'PHPBB_ROOT_PATH' )) ? PHPBB_ROOT_PATH : './' ;
2003-09-07 13:46:51 +00:00
$phpEx = substr ( strrchr ( __FILE__ , '.' ), 1 );
2006-06-06 20:53:46 +00:00
include ( $phpbb_root_path . 'common.' . $phpEx );
include ( $phpbb_root_path . 'includes/functions_posting.' . $phpEx );
2005-10-02 18:47:06 +00:00
include ( $phpbb_root_path . 'includes/functions_display.' . $phpEx );
2006-06-06 20:53:46 +00:00
include ( $phpbb_root_path . 'includes/message_parser.' . $phpEx );
2001-04-17 07:14:50 +00:00
2003-06-23 14:00:57 +00:00
2002-10-28 00:08:18 +00:00
// Start session management
2005-10-02 18:47:06 +00:00
$user -> session_begin ();
2002-10-28 00:08:18 +00:00
$auth -> acl ( $user -> data );
2003-06-23 14:00:57 +00:00
2003-01-22 16:35:06 +00:00
// Grab only parameters needed here
2003-10-09 14:48:55 +00:00
$post_id = request_var ( 'p' , 0 );
$topic_id = request_var ( 't' , 0 );
$forum_id = request_var ( 'f' , 0 );
2003-11-16 21:53:56 +00:00
$draft_id = request_var ( 'd' , 0 );
2003-10-09 14:48:55 +00:00
$lastclick = request_var ( 'lastclick' , 0 );
2003-06-17 19:34:17 +00:00
2006-05-12 20:52:58 +00:00
$submit = ( isset ( $_POST [ 'post' ])) ? true : false ;
$preview = ( isset ( $_POST [ 'preview' ])) ? true : false ;
$save = ( isset ( $_POST [ 'save' ])) ? true : false ;
$load = ( isset ( $_POST [ 'load' ])) ? true : false ;
$delete = ( isset ( $_POST [ 'delete' ])) ? true : false ;
2006-05-26 15:04:27 +00:00
$cancel = ( isset ( $_POST [ 'cancel' ]) && ! isset ( $_POST [ 'save' ])) ? true : false ;
2006-05-12 20:52:58 +00:00
2006-12-24 13:11:54 +00:00
$refresh = ( isset ( $_POST [ 'add_file' ]) || isset ( $_POST [ 'delete_file' ]) || isset ( $_POST [ 'cancel_unglobalise' ]) || $save || $load ) ? true : false ;
2004-01-25 14:30:15 +00:00
$mode = ( $delete && ! $preview && ! $refresh && $submit ) ? 'delete' : request_var ( 'mode' , '' );
2003-02-26 19:53:10 +00:00
2006-05-12 20:52:58 +00:00
$error = $post_data = array ();
2003-10-21 13:05:15 +00:00
$current_time = time ();
2003-06-24 16:46:30 +00:00
2007-10-03 15:05:54 +00:00
2002-10-20 19:19:07 +00:00
// Was cancel pressed? If so then redirect to the appropriate page
2004-05-26 18:20:33 +00:00
if ( $cancel || ( $current_time - $lastclick < 2 && $submit ))
2001-09-06 00:29:07 +00:00
{
2006-06-06 20:53:46 +00:00
$redirect = ( $post_id ) ? append_sid ( " { $phpbb_root_path } viewtopic. $phpEx " , 'p=' . $post_id ) . '#p' . $post_id : (( $topic_id ) ? append_sid ( " { $phpbb_root_path } viewtopic. $phpEx " , 't=' . $topic_id ) : (( $forum_id ) ? append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , 'f=' . $forum_id ) : append_sid ( " { $phpbb_root_path } index. $phpEx " )));
2002-10-20 19:19:07 +00:00
redirect ( $redirect );
2001-09-06 00:29:07 +00:00
}
2006-03-21 19:23:34 +00:00
if ( in_array ( $mode , array ( 'post' , 'reply' , 'quote' , 'edit' , 'delete' )) && ! $forum_id )
2003-08-30 12:21:31 +00:00
{
2003-10-12 09:18:56 +00:00
trigger_error ( 'NO_FORUM' );
2003-08-30 12:21:31 +00:00
}
2006-06-06 20:53:46 +00:00
// We need to know some basic information in all cases before we do anything.
2003-01-22 16:35:06 +00:00
switch ( $mode )
2002-02-18 12:34:38 +00:00
{
2002-10-28 00:08:18 +00:00
case 'post' :
2003-06-17 19:34:17 +00:00
$sql = ' SELECT *
FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id " ;
2006-01-22 13:06:13 +00:00
break ;
2002-10-30 00:57:27 +00:00
2003-10-19 15:36:45 +00:00
case 'bump' :
2002-10-04 13:09:10 +00:00
case 'reply' :
2003-02-26 13:17:45 +00:00
if ( ! $topic_id )
2002-03-21 01:03:47 +00:00
{
2003-10-12 09:18:56 +00:00
trigger_error ( 'NO_TOPIC' );
2002-03-21 01:03:47 +00:00
}
2004-09-01 08:40:54 +00:00
$sql = ' SELECT f .* , t .*
2003-06-17 19:34:17 +00:00
FROM ' . TOPICS_TABLE . ' t , ' . FORUMS_TABLE . " f
WHERE t . topic_id = $topic_id
2004-09-01 15:47:46 +00:00
AND ( f . forum_id = t . forum_id
2003-07-07 23:43:57 +00:00
OR f . forum_id = $forum_id ) " ;
2006-01-22 13:06:13 +00:00
break ;
2004-09-01 15:47:46 +00:00
2002-10-04 13:09:10 +00:00
case 'quote' :
2002-10-28 00:08:18 +00:00
case 'edit' :
2002-10-04 13:09:10 +00:00
case 'delete' :
2003-02-26 13:17:45 +00:00
if ( ! $post_id )
2002-10-04 13:09:10 +00:00
{
2007-04-15 14:38:23 +00:00
$user -> setup ( 'posting' );
2003-10-12 09:18:56 +00:00
trigger_error ( 'NO_POST' );
2002-10-04 13:09:10 +00:00
}
2001-09-06 00:29:07 +00:00
2006-12-02 13:19:40 +00:00
$sql = ' SELECT f .* , t .* , p .* , u . username , u . username_clean , u . user_sig , u . user_sig_bbcode_uid , u . user_sig_bbcode_bitfield
2003-06-17 19:34:17 +00:00
FROM ' . POSTS_TABLE . ' p , ' . TOPICS_TABLE . ' t , ' . FORUMS_TABLE . ' f , ' . USERS_TABLE . " u
WHERE p . post_id = $post_id
2002-10-04 13:09:10 +00:00
AND t . topic_id = p . topic_id
2003-02-28 12:57:10 +00:00
AND u . user_id = p . poster_id
2004-09-01 15:47:46 +00:00
AND ( f . forum_id = t . forum_id
2003-07-07 23:43:57 +00:00
OR f . forum_id = $forum_id ) " ;
2006-01-22 13:06:13 +00:00
break ;
2003-02-28 12:57:10 +00:00
2002-10-30 18:59:09 +00:00
case 'smilies' :
2004-05-02 13:06:57 +00:00
$sql = '' ;
2003-10-10 12:11:18 +00:00
generate_smilies ( 'window' , $forum_id );
2006-01-22 13:06:13 +00:00
break ;
2001-09-06 00:29:07 +00:00
2004-05-02 13:06:57 +00:00
case 'popup' :
2006-03-21 19:23:34 +00:00
if ( $forum_id )
{
$sql = ' SELECT forum_style
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $forum_id ;
}
else
{
upload_popup ();
2008-09-30 09:49:20 +00:00
return ;
2006-03-21 19:23:34 +00:00
}
2006-01-22 13:06:13 +00:00
break ;
2004-05-02 13:06:57 +00:00
2002-10-04 13:09:10 +00:00
default :
2003-06-24 16:46:30 +00:00
$sql = '' ;
2006-05-12 20:52:58 +00:00
break ;
2002-02-18 12:34:38 +00:00
}
2001-07-06 01:09:42 +00:00
2006-05-12 20:52:58 +00:00
if ( ! $sql )
2002-10-28 00:08:18 +00:00
{
2007-04-15 14:38:23 +00:00
$user -> setup ( 'posting' );
2006-05-12 20:52:58 +00:00
trigger_error ( 'NO_POST_MODE' );
}
2003-03-12 16:34:40 +00:00
2006-05-12 20:52:58 +00:00
$result = $db -> sql_query ( $sql );
$post_data = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
2003-02-27 23:37:02 +00:00
2006-10-11 13:48:30 +00:00
if ( ! $post_data )
{
2007-04-15 14:38:23 +00:00
if ( ! ( $mode == 'post' || $mode == 'bump' || $mode == 'reply' ))
{
$user -> setup ( 'posting' );
}
2006-10-11 13:48:30 +00:00
trigger_error (( $mode == 'post' || $mode == 'bump' || $mode == 'reply' ) ? 'NO_TOPIC' : 'NO_POST' );
}
2006-05-12 20:52:58 +00:00
if ( $mode == 'popup' )
2002-10-30 00:57:27 +00:00
{
2006-05-12 20:52:58 +00:00
upload_popup ( $post_data [ 'forum_style' ]);
2008-09-30 09:49:20 +00:00
return ;
2002-10-30 00:57:27 +00:00
}
2006-05-12 20:52:58 +00:00
2006-07-17 15:32:46 +00:00
$user -> setup ( array ( 'posting' , 'mcp' , 'viewtopic' ), $post_data [ 'forum_style' ]);
2006-05-12 20:52:58 +00:00
// Use post_row values in favor of submitted ones...
$forum_id = ( ! empty ( $post_data [ 'forum_id' ])) ? ( int ) $post_data [ 'forum_id' ] : ( int ) $forum_id ;
$topic_id = ( ! empty ( $post_data [ 'topic_id' ])) ? ( int ) $post_data [ 'topic_id' ] : ( int ) $topic_id ;
$post_id = ( ! empty ( $post_data [ 'post_id' ])) ? ( int ) $post_data [ 'post_id' ] : ( int ) $post_id ;
// Need to login to passworded forum first?
if ( $post_data [ 'forum_password' ])
2003-06-06 19:05:21 +00:00
{
2006-05-12 20:52:58 +00:00
login_forum_box ( array (
'forum_id' => $forum_id ,
'forum_password' => $post_data [ 'forum_password' ])
);
2003-06-06 19:05:21 +00:00
}
2002-10-30 00:57:27 +00:00
2006-04-06 17:15:45 +00:00
// Check permissions
2007-06-27 16:02:41 +00:00
if ( $user -> data [ 'is_bot' ])
{
redirect ( append_sid ( " { $phpbb_root_path } index. $phpEx " ));
}
2006-05-12 20:52:58 +00:00
// Is the user able to read within this forum?
if ( ! $auth -> acl_get ( 'f_read' , $forum_id ))
2002-10-20 19:19:07 +00:00
{
2006-11-20 16:40:44 +00:00
if ( $user -> data [ 'user_id' ] != ANONYMOUS )
2004-02-21 12:47:35 +00:00
{
2006-04-06 17:15:45 +00:00
trigger_error ( 'USER_CANNOT_READ' );
2004-02-21 12:47:35 +00:00
}
2004-09-01 15:47:46 +00:00
2006-04-06 17:15:45 +00:00
login_box ( '' , $user -> lang [ 'LOGIN_EXPLAIN_POST' ]);
2002-10-28 00:08:18 +00:00
}
2001-05-27 03:11:27 +00:00
2006-05-12 20:52:58 +00:00
// Permission to do the action asked?
2006-07-01 19:11:52 +00:00
$is_authed = false ;
switch ( $mode )
2006-04-06 17:15:45 +00:00
{
2006-07-01 19:11:52 +00:00
case 'post' :
if ( $auth -> acl_get ( 'f_post' , $forum_id ))
{
$is_authed = true ;
}
break ;
case 'bump' :
if ( $auth -> acl_get ( 'f_bump' , $forum_id ))
{
$is_authed = true ;
}
break ;
case 'quote' :
2007-01-03 16:38:25 +00:00
$post_data [ 'post_edit_locked' ] = 0 ;
// no break;
2006-07-01 19:11:52 +00:00
case 'reply' :
if ( $auth -> acl_get ( 'f_reply' , $forum_id ))
{
$is_authed = true ;
}
break ;
case 'edit' :
if ( $user -> data [ 'is_registered' ] && $auth -> acl_gets ( 'f_edit' , 'm_edit' , $forum_id ))
{
$is_authed = true ;
}
break ;
case 'delete' :
if ( $user -> data [ 'is_registered' ] && $auth -> acl_gets ( 'f_delete' , 'm_delete' , $forum_id ))
{
$is_authed = true ;
}
break ;
}
if ( ! $is_authed )
{
$check_auth = ( $mode == 'quote' ) ? 'reply' : $mode ;
2006-04-06 17:15:45 +00:00
if ( $user -> data [ 'is_registered' ])
{
trigger_error ( 'USER_CANNOT_' . strtoupper ( $check_auth ));
}
login_box ( '' , $user -> lang [ 'LOGIN_EXPLAIN_' . strtoupper ( $mode )]);
}
2003-06-23 14:00:57 +00:00
2006-05-12 20:52:58 +00:00
// Is the user able to post within this forum?
if ( $post_data [ 'forum_type' ] != FORUM_POST && in_array ( $mode , array ( 'post' , 'bump' , 'quote' , 'reply' )))
{
trigger_error ( 'USER_CANNOT_FORUM_POST' );
}
2002-11-01 12:23:08 +00:00
// Forum/Topic locked?
2006-05-12 20:52:58 +00:00
if (( $post_data [ 'forum_status' ] == ITEM_LOCKED || ( isset ( $post_data [ 'topic_status' ]) && $post_data [ 'topic_status' ] == ITEM_LOCKED )) && ! $auth -> acl_get ( 'm_edit' , $forum_id ))
2002-11-01 12:23:08 +00:00
{
2006-05-12 20:52:58 +00:00
trigger_error (( $post_data [ 'forum_status' ] == ITEM_LOCKED ) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED' );
2002-11-01 12:23:08 +00:00
}
2004-09-01 15:47:46 +00:00
// Can we edit this post ... if we're a moderator with rights then always yes
// else it depends on editing times, lock status and if we're the correct user
2006-05-12 20:52:58 +00:00
if ( $mode == 'edit' && ! $auth -> acl_get ( 'm_edit' , $forum_id ))
2002-10-28 00:08:18 +00:00
{
2006-05-12 20:52:58 +00:00
if ( $user -> data [ 'user_id' ] != $post_data [ 'poster_id' ])
2004-09-01 15:47:46 +00:00
{
trigger_error ( 'USER_CANNOT_EDIT' );
}
2006-06-19 21:30:32 +00:00
if ( ! ( $post_data [ 'post_time' ] > time () - ( $config [ 'edit_time' ] * 60 ) || ! $config [ 'edit_time' ]))
2004-05-02 13:06:57 +00:00
{
trigger_error ( 'CANNOT_EDIT_TIME' );
}
2001-05-26 00:25:50 +00:00
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'post_edit_locked' ])
2004-05-02 13:06:57 +00:00
{
trigger_error ( 'CANNOT_EDIT_POST_LOCKED' );
}
2003-02-26 19:53:10 +00:00
}
2006-05-12 20:52:58 +00:00
// Handle delete mode...
if ( $mode == 'delete' )
2003-04-16 21:16:57 +00:00
{
2006-05-12 20:52:58 +00:00
handle_post_delete ( $forum_id , $topic_id , $post_id , $post_data );
2008-09-30 09:49:20 +00:00
return ;
2003-04-16 21:16:57 +00:00
}
2006-05-12 20:52:58 +00:00
// Handle bump mode...
if ( $mode == 'bump' )
2003-03-02 13:32:53 +00:00
{
2008-08-21 15:41:12 +00:00
if ( $bump_time = bump_topic_allowed ( $forum_id , $post_data [ 'topic_bumped' ], $post_data [ 'topic_last_post_time' ], $post_data [ 'topic_poster' ], $post_data [ 'topic_last_poster_id' ])
2008-09-26 13:14:11 +00:00
&& check_link_hash ( request_var ( 'hash' , '' ), " topic_ { $post_data [ 'topic_id' ] } " ))
2003-03-02 13:32:53 +00:00
{
2006-06-06 20:53:46 +00:00
$db -> sql_transaction ( 'begin' );
2004-09-01 15:47:46 +00:00
2006-06-06 20:53:46 +00:00
$sql = 'UPDATE ' . POSTS_TABLE . "
2006-05-12 20:52:58 +00:00
SET post_time = $current_time
WHERE post_id = { $post_data [ 'topic_last_post_id' ]}
2006-06-06 20:53:46 +00:00
AND topic_id = $topic_id " ;
$db -> sql_query ( $sql );
2004-09-01 15:47:46 +00:00
2006-06-06 20:53:46 +00:00
$sql = 'UPDATE ' . TOPICS_TABLE . "
2006-05-12 20:52:58 +00:00
SET topic_last_post_time = $current_time ,
topic_bumped = 1 ,
topic_bumper = " . $user->data ['user_id'] . "
2006-06-06 20:53:46 +00:00
WHERE topic_id = $topic_id " ;
$db -> sql_query ( $sql );
2005-06-10 18:57:21 +00:00
2006-05-12 20:52:58 +00:00
update_post_information ( 'forum' , $forum_id );
2005-06-10 18:57:21 +00:00
2006-06-06 20:53:46 +00:00
$sql = 'UPDATE ' . USERS_TABLE . "
2006-05-12 20:52:58 +00:00
SET user_lastpost_time = $current_time
2006-06-06 20:53:46 +00:00
WHERE user_id = " . $user->data ['user_id'];
$db -> sql_query ( $sql );
2006-05-12 20:52:58 +00:00
$db -> sql_transaction ( 'commit' );
markread ( 'post' , $forum_id , $topic_id , $current_time );
2006-06-08 10:59:36 +00:00
add_log ( 'mod' , $forum_id , $topic_id , 'LOG_BUMP_TOPIC' , $post_data [ 'topic_title' ]);
2006-05-12 20:52:58 +00:00
2006-06-06 20:53:46 +00:00
$meta_url = append_sid ( " { $phpbb_root_path } viewtopic. $phpEx " , " f= $forum_id &t= $topic_id &p= { $post_data [ 'topic_last_post_id' ] } " ) . " #p { $post_data [ 'topic_last_post_id' ] } " ;
2006-05-12 20:52:58 +00:00
meta_refresh ( 3 , $meta_url );
$message = $user -> lang [ 'TOPIC_BUMPED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'VIEW_MESSAGE' ], '<a href="' . $meta_url . '">' , '</a>' );
2006-06-06 20:53:46 +00:00
$message .= '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_FORUM' ], '<a href="' . append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , 'f=' . $forum_id ) . '">' , '</a>' );
2003-04-18 13:07:19 +00:00
trigger_error ( $message );
2003-03-02 13:32:53 +00:00
}
2006-06-06 20:53:46 +00:00
2006-05-12 20:52:58 +00:00
trigger_error ( 'BUMP_ERROR' );
}
2007-08-16 11:28:58 +00:00
// Subject length limiting to 60 characters if first post...
if ( $mode == 'post' || ( $mode == 'edit' && $post_data [ 'topic_first_post_id' ] == $post_data [ 'post_id' ]))
{
$template -> assign_var ( 'S_NEW_MESSAGE' , true );
}
2006-05-12 20:52:58 +00:00
// Determine some vars
2007-06-18 15:12:14 +00:00
if ( isset ( $post_data [ 'poster_id' ]) && $post_data [ 'poster_id' ] == ANONYMOUS )
{
$post_data [ 'quote_username' ] = ( ! empty ( $post_data [ 'post_username' ])) ? $post_data [ 'post_username' ] : $user -> lang [ 'GUEST' ];
}
else
{
$post_data [ 'quote_username' ] = isset ( $post_data [ 'username' ]) ? $post_data [ 'username' ] : '' ;
}
2007-08-16 11:28:58 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'post_edit_locked' ] = ( isset ( $post_data [ 'post_edit_locked' ])) ? ( int ) $post_data [ 'post_edit_locked' ] : 0 ;
$post_data [ 'post_subject' ] = ( in_array ( $mode , array ( 'quote' , 'edit' ))) ? $post_data [ 'post_subject' ] : (( isset ( $post_data [ 'topic_title' ])) ? $post_data [ 'topic_title' ] : '' );
$post_data [ 'topic_time_limit' ] = ( isset ( $post_data [ 'topic_time_limit' ])) ? (( $post_data [ 'topic_time_limit' ]) ? ( int ) $post_data [ 'topic_time_limit' ] / 86400 : ( int ) $post_data [ 'topic_time_limit' ]) : 0 ;
$post_data [ 'poll_length' ] = ( ! empty ( $post_data [ 'poll_length' ])) ? ( int ) $post_data [ 'poll_length' ] / 86400 : 0 ;
$post_data [ 'poll_start' ] = ( ! empty ( $post_data [ 'poll_start' ])) ? ( int ) $post_data [ 'poll_start' ] : 0 ;
$post_data [ 'icon_id' ] = ( ! isset ( $post_data [ 'icon_id' ]) || in_array ( $mode , array ( 'quote' , 'reply' ))) ? 0 : ( int ) $post_data [ 'icon_id' ];
$post_data [ 'poll_options' ] = array ();
// Get Poll Data
if ( $post_data [ 'poll_start' ])
{
$sql = ' SELECT poll_option_text
FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = $topic_id
ORDER BY poll_option_id " ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
2003-03-02 13:32:53 +00:00
{
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_options' ][] = trim ( $row [ 'poll_option_text' ]);
2003-03-02 13:32:53 +00:00
}
2006-05-12 20:52:58 +00:00
$db -> sql_freeresult ( $result );
2003-03-02 13:32:53 +00:00
}
2006-05-12 20:52:58 +00:00
$orig_poll_options_size = sizeof ( $post_data [ 'poll_options' ]);
2003-06-23 14:00:57 +00:00
2006-05-12 20:52:58 +00:00
$message_parser = new parse_message ();
if ( isset ( $post_data [ 'post_text' ]))
2003-03-02 13:32:53 +00:00
{
2006-05-12 20:52:58 +00:00
$message_parser -> message = & $post_data [ 'post_text' ];
unset ( $post_data [ 'post_text' ]);
2003-03-02 13:32:53 +00:00
}
2006-05-12 20:52:58 +00:00
// Set some default variables
2006-05-17 16:58:56 +00:00
$uninit = array ( 'post_attachment' => 0 , 'poster_id' => $user -> data [ 'user_id' ], 'enable_magic_url' => 0 , 'topic_status' => 0 , 'topic_type' => POST_NORMAL , 'post_subject' => '' , 'topic_title' => '' , 'post_time' => 0 , 'post_edit_reason' => '' , 'notify_set' => 0 );
2006-06-06 10:54:51 +00:00
2006-05-12 20:52:58 +00:00
foreach ( $uninit as $var_name => $default_value )
2003-03-02 13:32:53 +00:00
{
2006-05-12 20:52:58 +00:00
if ( ! isset ( $post_data [ $var_name ]))
{
$post_data [ $var_name ] = $default_value ;
}
2003-03-02 13:32:53 +00:00
}
2006-05-12 20:52:58 +00:00
unset ( $uninit );
2003-03-02 13:32:53 +00:00
2006-09-13 16:08:36 +00:00
// Always check if the submitted attachment data is valid and belongs to the user.
// Further down (especially in submit_post()) we do not check this again.
2006-06-06 10:54:51 +00:00
$message_parser -> get_submitted_attachment_data ( $post_data [ 'poster_id' ]);
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'post_attachment' ] && ! $submit && ! $refresh && ! $preview && $mode == 'edit' )
2003-03-02 13:32:53 +00:00
{
2006-06-06 20:53:46 +00:00
// Do not change to SELECT *
2006-09-13 16:08:36 +00:00
$sql = ' SELECT attach_id , is_orphan , attach_comment , real_filename
2006-05-12 20:52:58 +00:00
FROM ' . ATTACHMENTS_TABLE . "
WHERE post_msg_id = $post_id
AND in_message = 0
2006-09-13 16:08:36 +00:00
AND is_orphan = 0
2006-11-21 18:15:53 +00:00
ORDER BY filetime DESC " ;
2006-05-12 20:52:58 +00:00
$result = $db -> sql_query ( $sql );
$message_parser -> attachment_data = array_merge ( $message_parser -> attachment_data , $db -> sql_fetchrowset ( $result ));
$db -> sql_freeresult ( $result );
2003-03-02 13:32:53 +00:00
}
2002-11-07 22:02:49 +00:00
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'poster_id' ] == ANONYMOUS )
2003-10-19 15:36:45 +00:00
{
2006-05-12 20:52:58 +00:00
$post_data [ 'username' ] = ( $mode == 'quote' || $mode == 'edit' ) ? trim ( $post_data [ 'post_username' ]) : '' ;
}
else
{
$post_data [ 'username' ] = ( $mode == 'quote' || $mode == 'edit' ) ? trim ( $post_data [ 'username' ]) : '' ;
}
2003-10-19 15:36:45 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'enable_urls' ] = $post_data [ 'enable_magic_url' ];
2003-10-19 15:36:45 +00:00
2006-05-12 20:52:58 +00:00
if ( $mode != 'edit' )
{
$post_data [ 'enable_sig' ] = ( $config [ 'allow_sig' ] && $user -> optionget ( 'attachsig' )) ? true : false ;
$post_data [ 'enable_smilies' ] = ( $config [ 'allow_smilies' ] && $user -> optionget ( 'smilies' )) ? true : false ;
$post_data [ 'enable_bbcode' ] = ( $config [ 'allow_bbcode' ] && $user -> optionget ( 'bbcode' )) ? true : false ;
$post_data [ 'enable_urls' ] = true ;
}
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'enable_magic_url' ] = $post_data [ 'drafts' ] = false ;
2003-10-19 15:36:45 +00:00
2006-05-12 20:52:58 +00:00
// User own some drafts?
#10005, #10003, #10001, #9999, #9945, #9965, #9909, #9906, #9877, #9861, #9831, #9830, #9815, #9665, #9624
prosilver adjustments for important announcements in ucp - #9995
MCP fixes for user notes/warnings - #9981
Preserving imageset values on save/edit
find a member link for Mass PM's - #9925
syndicate window.onload events where necessary - #9878
Duplicate topics in forums with announcements - #9840
Email template for forced re-activation - #9808
Topic pagination adjustment - #9763
Changed compose message layout in UCP - #9706, #9702
Fixed inline attachment font size (hopefully)
git-svn-id: file:///svn/phpbb/trunk@7384 89ea8834-ac86-4346-8a33-228a782c2dd0
2007-04-22 15:27:40 +00:00
if ( $user -> data [ 'is_registered' ] && $auth -> acl_get ( 'u_savedrafts' ) && ( $mode == 'reply' || $mode == 'post' || $mode == 'quote' ))
2006-05-12 20:52:58 +00:00
{
$sql = ' SELECT draft_id
FROM ' . DRAFTS_TABLE . '
2007-05-17 13:01:17 +00:00
WHERE user_id = ' . $user->data[' user_id ' ] .
2007-10-05 14:30:11 +00:00
(( $forum_id ) ? ' AND forum_id = ' . ( int ) $forum_id : '' ) .
2007-05-17 13:01:17 +00:00
(( $topic_id ) ? ' AND topic_id = ' . ( int ) $topic_id : '' ) .
2006-05-12 20:52:58 +00:00
(( $draft_id ) ? " AND draft_id <> $draft_id " : '' );
$result = $db -> sql_query_limit ( $sql , 1 );
2003-10-22 20:41:00 +00:00
2006-05-12 20:52:58 +00:00
if ( $db -> sql_fetchrow ( $result ))
{
$post_data [ 'drafts' ] = true ;
}
$db -> sql_freeresult ( $result );
}
2003-10-19 15:36:45 +00:00
2006-05-12 20:52:58 +00:00
$check_value = (( $post_data [ 'enable_bbcode' ] + 1 ) << 8 ) + (( $post_data [ 'enable_smilies' ] + 1 ) << 4 ) + (( $post_data [ 'enable_urls' ] + 1 ) << 2 ) + (( $post_data [ 'enable_sig' ] + 1 ) << 1 );
2004-01-25 14:30:15 +00:00
2006-05-12 20:52:58 +00:00
// Check if user is watching this topic
2006-05-20 16:23:25 +00:00
if ( $mode != 'post' && $config [ 'allow_topic_notify' ] && $user -> data [ 'is_registered' ])
2006-05-12 20:52:58 +00:00
{
$sql = ' SELECT topic_id
FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND user_id = ' . $user->data[' user_id ' ];
$result = $db -> sql_query ( $sql );
$post_data [ 'notify_set' ] = ( int ) $db -> sql_fetchfield ( 'topic_id' );
$db -> sql_freeresult ( $result );
2003-10-19 15:36:45 +00:00
}
2006-05-12 20:52:58 +00:00
// Do we want to edit our post ?
2006-06-16 16:54:51 +00:00
if ( $mode == 'edit' && $post_data [ 'bbcode_uid' ])
2003-11-01 16:10:21 +00:00
{
2006-05-12 20:52:58 +00:00
$message_parser -> bbcode_uid = $post_data [ 'bbcode_uid' ];
2003-11-01 16:10:21 +00:00
}
2003-10-19 15:36:45 +00:00
2006-05-12 20:52:58 +00:00
// HTML, BBCode, Smilies, Images and Flash status
$bbcode_status = ( $config [ 'allow_bbcode' ] && $auth -> acl_get ( 'f_bbcode' , $forum_id )) ? true : false ;
2007-03-30 10:49:06 +00:00
$smilies_status = ( $bbcode_status && $config [ 'allow_smilies' ] && $auth -> acl_get ( 'f_smilies' , $forum_id )) ? true : false ;
$img_status = ( $bbcode_status && $auth -> acl_get ( 'f_img' , $forum_id )) ? true : false ;
2006-09-13 16:08:36 +00:00
$url_status = ( $config [ 'allow_post_links' ]) ? true : false ;
2007-06-06 14:00:52 +00:00
$flash_status = ( $bbcode_status && $auth -> acl_get ( 'f_flash' , $forum_id ) && $config [ 'allow_post_flash' ]) ? true : false ;
2006-05-12 20:52:58 +00:00
$quote_status = ( $auth -> acl_get ( 'f_reply' , $forum_id )) ? true : false ;
2003-09-04 18:30:20 +00:00
// Save Draft
#10005, #10003, #10001, #9999, #9945, #9965, #9909, #9906, #9877, #9861, #9831, #9830, #9815, #9665, #9624
prosilver adjustments for important announcements in ucp - #9995
MCP fixes for user notes/warnings - #9981
Preserving imageset values on save/edit
find a member link for Mass PM's - #9925
syndicate window.onload events where necessary - #9878
Duplicate topics in forums with announcements - #9840
Email template for forced re-activation - #9808
Topic pagination adjustment - #9763
Changed compose message layout in UCP - #9706, #9702
Fixed inline attachment font size (hopefully)
git-svn-id: file:///svn/phpbb/trunk@7384 89ea8834-ac86-4346-8a33-228a782c2dd0
2007-04-22 15:27:40 +00:00
if ( $save && $user -> data [ 'is_registered' ] && $auth -> acl_get ( 'u_savedrafts' ) && ( $mode == 'reply' || $mode == 'post' || $mode == 'quote' ))
2003-09-04 18:30:20 +00:00
{
2006-11-15 15:35:50 +00:00
$subject = utf8_normalize_nfc ( request_var ( 'subject' , '' , true ));
2006-05-12 20:52:58 +00:00
$subject = ( ! $subject && $mode != 'post' ) ? $post_data [ 'topic_title' ] : $subject ;
2006-11-15 15:35:50 +00:00
$message = utf8_normalize_nfc ( request_var ( 'message' , '' , true ));
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
2004-03-11 21:17:32 +00:00
if ( $subject && $message )
2003-11-16 21:53:56 +00:00
{
2006-05-26 15:04:27 +00:00
if ( confirm_box ( true ))
{
$sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db -> sql_build_array ( 'INSERT' , array (
2007-07-27 17:33:27 +00:00
'user_id' => ( int ) $user -> data [ 'user_id' ],
'topic_id' => ( int ) $topic_id ,
'forum_id' => ( int ) $forum_id ,
'save_time' => ( int ) $current_time ,
'draft_subject' => ( string ) $subject ,
'draft_message' => ( string ) $message )
2006-05-26 15:04:27 +00:00
);
$db -> sql_query ( $sql );
2004-09-01 15:47:46 +00:00
2006-06-06 20:53:46 +00:00
$meta_info = ( $mode == 'post' ) ? append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , 'f=' . $forum_id ) : append_sid ( " { $phpbb_root_path } viewtopic. $phpEx " , " f= $forum_id &t= $topic_id " );
2003-09-04 18:30:20 +00:00
2006-05-26 15:04:27 +00:00
meta_refresh ( 3 , $meta_info );
2003-11-16 21:53:56 +00:00
2006-05-26 15:04:27 +00:00
$message = $user -> lang [ 'DRAFT_SAVED' ] . '<br /><br />' ;
$message .= ( $mode != 'post' ) ? sprintf ( $user -> lang [ 'RETURN_TOPIC' ], '<a href="' . $meta_info . '">' , '</a>' ) . '<br /><br />' : '' ;
2006-06-06 20:53:46 +00:00
$message .= sprintf ( $user -> lang [ 'RETURN_FORUM' ], '<a href="' . append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , 'f=' . $forum_id ) . '">' , '</a>' );
2003-11-16 21:53:56 +00:00
2006-05-26 15:04:27 +00:00
trigger_error ( $message );
}
else
{
$s_hidden_fields = build_hidden_fields ( array (
'mode' => $mode ,
'save' => true ,
'f' => $forum_id ,
't' => $topic_id ,
'subject' => $subject ,
'message' => $message ,
2008-02-14 12:33:11 +00:00
'attachment_data' => $message_parser -> attachment_data ,
2006-07-09 16:23:57 +00:00
)
2006-05-26 15:04:27 +00:00
);
confirm_box ( false , 'SAVE_DRAFT' , $s_hidden_fields );
}
2003-09-04 18:30:20 +00:00
}
2006-12-24 06:26:03 +00:00
else
{
2008-01-05 16:10:10 +00:00
if ( utf8_clean_string ( $subject ) === '' )
2006-12-24 06:26:03 +00:00
{
$error [] = $user -> lang [ 'EMPTY_SUBJECT' ];
}
2008-01-05 16:10:10 +00:00
if ( utf8_clean_string ( $message ) === '' )
2006-12-24 06:26:03 +00:00
{
$error [] = $user -> lang [ 'TOO_FEW_CHARS' ];
}
}
2006-05-12 20:52:58 +00:00
unset ( $subject , $message );
2003-09-04 18:30:20 +00:00
}
2006-05-12 20:52:58 +00:00
// Load requested Draft
#10005, #10003, #10001, #9999, #9945, #9965, #9909, #9906, #9877, #9861, #9831, #9830, #9815, #9665, #9624
prosilver adjustments for important announcements in ucp - #9995
MCP fixes for user notes/warnings - #9981
Preserving imageset values on save/edit
find a member link for Mass PM's - #9925
syndicate window.onload events where necessary - #9878
Duplicate topics in forums with announcements - #9840
Email template for forced re-activation - #9808
Topic pagination adjustment - #9763
Changed compose message layout in UCP - #9706, #9702
Fixed inline attachment font size (hopefully)
git-svn-id: file:///svn/phpbb/trunk@7384 89ea8834-ac86-4346-8a33-228a782c2dd0
2007-04-22 15:27:40 +00:00
if ( $draft_id && ( $mode == 'reply' || $mode == 'quote' || $mode == 'post' ) && $user -> data [ 'is_registered' ] && $auth -> acl_get ( 'u_savedrafts' ))
2003-11-16 21:53:56 +00:00
{
2004-09-01 15:47:46 +00:00
$sql = ' SELECT draft_subject , draft_message
FROM ' . DRAFTS_TABLE . "
2003-11-16 21:53:56 +00:00
WHERE draft_id = $draft_id
AND user_id = " . $user->data ['user_id'];
$result = $db -> sql_query_limit ( $sql , 1 );
2006-05-12 20:52:58 +00:00
$row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
if ( $row )
2003-11-16 21:53:56 +00:00
{
2006-05-17 16:58:56 +00:00
$post_data [ 'post_subject' ] = $row [ 'draft_subject' ];
$message_parser -> message = $row [ 'draft_message' ];
2003-11-16 21:53:56 +00:00
$template -> assign_var ( 'S_DRAFT_LOADED' , true );
}
else
{
$draft_id = 0 ;
}
}
2006-05-12 20:52:58 +00:00
// Load draft overview
#10005, #10003, #10001, #9999, #9945, #9965, #9909, #9906, #9877, #9861, #9831, #9830, #9815, #9665, #9624
prosilver adjustments for important announcements in ucp - #9995
MCP fixes for user notes/warnings - #9981
Preserving imageset values on save/edit
find a member link for Mass PM's - #9925
syndicate window.onload events where necessary - #9878
Duplicate topics in forums with announcements - #9840
Email template for forced re-activation - #9808
Topic pagination adjustment - #9763
Changed compose message layout in UCP - #9706, #9702
Fixed inline attachment font size (hopefully)
git-svn-id: file:///svn/phpbb/trunk@7384 89ea8834-ac86-4346-8a33-228a782c2dd0
2007-04-22 15:27:40 +00:00
if ( $load && ( $mode == 'reply' || $mode == 'quote' || $mode == 'post' ) && $post_data [ 'drafts' ])
2003-11-16 21:53:56 +00:00
{
load_drafts ( $topic_id , $forum_id );
}
2003-09-04 18:30:20 +00:00
2006-10-06 21:37:17 +00:00
$solved_captcha = false ;
2003-05-02 15:50:11 +00:00
if ( $submit || $preview || $refresh )
2002-10-04 13:09:10 +00:00
{
2006-11-15 15:35:50 +00:00
$post_data [ 'topic_cur_post_id' ] = request_var ( 'topic_cur_post_id' , 0 );
2007-07-22 20:11:45 +00:00
$post_data [ 'post_subject' ] = utf8_normalize_nfc ( request_var ( 'subject' , '' , true ));
2006-11-15 15:35:50 +00:00
$message_parser -> message = utf8_normalize_nfc ( request_var ( 'message' , '' , true ));
2003-09-08 07:05:29 +00:00
2006-11-15 15:35:50 +00:00
$post_data [ 'username' ] = utf8_normalize_nfc ( request_var ( 'username' , $post_data [ 'username' ], true ));
$post_data [ 'post_edit_reason' ] = ( ! empty ( $_POST [ 'edit_reason' ]) && $mode == 'edit' && $auth -> acl_get ( 'm_edit' , $forum_id )) ? utf8_normalize_nfc ( request_var ( 'edit_reason' , '' , true )) : '' ;
2007-01-17 18:41:49 +00:00
$post_data [ 'orig_topic_type' ] = $post_data [ 'topic_type' ];
2006-05-12 20:52:58 +00:00
$post_data [ 'topic_type' ] = request_var ( 'topic_type' , (( $mode != 'post' ) ? ( int ) $post_data [ 'topic_type' ] : POST_NORMAL ));
$post_data [ 'topic_time_limit' ] = request_var ( 'topic_time_limit' , (( $mode != 'post' ) ? ( int ) $post_data [ 'topic_time_limit' ] : 0 ));
$post_data [ 'icon_id' ] = request_var ( 'icon' , 0 );
2003-03-10 19:39:50 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'enable_bbcode' ] = ( ! $bbcode_status || isset ( $_POST [ 'disable_bbcode' ])) ? false : true ;
$post_data [ 'enable_smilies' ] = ( ! $smilies_status || isset ( $_POST [ 'disable_smilies' ])) ? false : true ;
$post_data [ 'enable_urls' ] = ( isset ( $_POST [ 'disable_magic_url' ])) ? 0 : 1 ;
2008-02-01 13:12:05 +00:00
$post_data [ 'enable_sig' ] = ( ! $config [ 'allow_sig' ] || ! $auth -> acl_get ( 'f_sigs' , $forum_id ) || ! $auth -> acl_get ( 'u_sig' )) ? false : (( isset ( $_POST [ 'attach_sig' ]) && $user -> data [ 'is_registered' ]) ? true : false );
2003-03-10 19:39:50 +00:00
2006-05-20 16:23:25 +00:00
if ( $config [ 'allow_topic_notify' ] && $user -> data [ 'is_registered' ])
{
$notify = ( isset ( $_POST [ 'notify' ])) ? true : false ;
}
else
{
$notify = false ;
}
2006-05-12 20:52:58 +00:00
$topic_lock = ( isset ( $_POST [ 'lock_topic' ])) ? true : false ;
$post_lock = ( isset ( $_POST [ 'lock_post' ])) ? true : false ;
$poll_delete = ( isset ( $_POST [ 'poll_delete' ])) ? true : false ;
2004-09-01 15:47:46 +00:00
2004-09-04 19:32:23 +00:00
if ( $submit )
{
2006-05-12 20:52:58 +00:00
$status_switch = (( $post_data [ 'enable_bbcode' ] + 1 ) << 8 ) + (( $post_data [ 'enable_smilies' ] + 1 ) << 4 ) + (( $post_data [ 'enable_urls' ] + 1 ) << 2 ) + (( $post_data [ 'enable_sig' ] + 1 ) << 1 );
2004-09-04 19:32:23 +00:00
$status_switch = ( $status_switch != $check_value );
}
else
{
$status_switch = 1 ;
}
2003-06-23 14:00:57 +00:00
2004-09-05 15:45:50 +00:00
// Delete Poll
2007-10-05 14:30:11 +00:00
if ( $poll_delete && $mode == 'edit' && sizeof ( $post_data [ 'poll_options' ]) &&
2006-05-12 20:52:58 +00:00
(( ! $post_data [ 'poll_last_vote' ] && $post_data [ 'poster_id' ] == $user -> data [ 'user_id' ] && $auth -> acl_get ( 'f_delete' , $forum_id )) || $auth -> acl_get ( 'm_delete' , $forum_id )))
2003-03-10 19:39:50 +00:00
{
2007-12-05 15:24:58 +00:00
if ( $submit && check_form_key ( 'posting' ))
2006-10-20 13:48:44 +00:00
{
$sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . "
WHERE topic_id = $topic_id " ;
$db -> sql_query ( $sql );
2006-07-10 15:55:10 +00:00
2006-10-20 13:48:44 +00:00
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . "
WHERE topic_id = $topic_id " ;
$db -> sql_query ( $sql );
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
2006-10-20 13:48:44 +00:00
$topic_sql = array (
'poll_title' => '' ,
'poll_start' => 0 ,
'poll_length' => 0 ,
'poll_last_vote' => 0 ,
'poll_max_options' => 0 ,
'poll_vote_change' => 0
);
2003-04-18 13:07:19 +00:00
2006-10-20 13:48:44 +00:00
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array(' UPDATE ' , $topic_sql ) . "
WHERE topic_id = $topic_id " ;
$db -> sql_query ( $sql );
}
2003-03-10 19:39:50 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_title' ] = $post_data [ 'poll_option_text' ] = '' ;
$post_data [ 'poll_vote_change' ] = $post_data [ 'poll_max_options' ] = $post_data [ 'poll_length' ] = 0 ;
2003-03-10 19:39:50 +00:00
}
else
{
2006-11-15 15:35:50 +00:00
$post_data [ 'poll_title' ] = utf8_normalize_nfc ( request_var ( 'poll_title' , '' , true ));
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_length' ] = request_var ( 'poll_length' , 0 );
2006-11-15 15:35:50 +00:00
$post_data [ 'poll_option_text' ] = utf8_normalize_nfc ( request_var ( 'poll_option_text' , '' , true ));
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_max_options' ] = request_var ( 'poll_max_options' , 1 );
$post_data [ 'poll_vote_change' ] = ( $auth -> acl_get ( 'f_votechg' , $forum_id ) && isset ( $_POST [ 'poll_vote_change' ])) ? 1 : 0 ;
2003-03-10 19:39:50 +00:00
}
2003-02-27 23:37:02 +00:00
2002-11-21 01:35:53 +00:00
// If replying/quoting and last post id has changed
2003-06-06 19:05:21 +00:00
// give user option to continue submit or return to post
2003-02-26 13:17:45 +00:00
// notify and show user the post made between his request and the final submit
2006-05-12 20:52:58 +00:00
if (( $mode == 'reply' || $mode == 'quote' ) && $post_data [ 'topic_cur_post_id' ] && $post_data [ 'topic_cur_post_id' ] != $post_data [ 'topic_last_post_id' ])
2002-11-21 01:35:53 +00:00
{
2006-07-09 16:23:57 +00:00
// Only do so if it is allowed forum-wide
2006-09-13 16:08:36 +00:00
if ( $post_data [ 'forum_flags' ] & FORUM_FLAG_POST_REVIEW )
2003-04-20 16:49:26 +00:00
{
2006-07-09 16:23:57 +00:00
if ( topic_review ( $topic_id , $forum_id , 'post_review' , $post_data [ 'topic_cur_post_id' ]))
{
$template -> assign_var ( 'S_POST_REVIEW' , true );
}
2006-05-12 20:52:58 +00:00
2006-07-09 16:23:57 +00:00
$submit = false ;
$refresh = true ;
}
2002-11-21 01:35:53 +00:00
}
2004-02-08 18:02:17 +00:00
// Parse Attachments - before checksum is calculated
2005-03-21 22:43:07 +00:00
$message_parser -> parse_attachments ( 'fileupload' , $mode , $forum_id , $submit , $preview , $refresh );
2003-06-24 16:46:30 +00:00
2003-01-22 16:35:06 +00:00
// Grab md5 'checksum' of new message
2003-04-11 19:51:38 +00:00
$message_md5 = md5 ( $message_parser -> message );
2002-10-30 00:57:27 +00:00
// Check checksum ... don't re-parse message if the same
2007-10-04 04:42:39 +00:00
$update_message = ( $mode != 'edit' || $message_md5 != $post_data [ 'post_checksum' ] || $status_switch || strlen ( $post_data [ 'bbcode_uid' ]) < BBCODE_UID_LEN ) ? true : false ;
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
2004-07-27 19:47:27 +00:00
// Parse message
if ( $update_message )
2002-10-04 13:09:10 +00:00
{
2006-09-28 15:04:59 +00:00
if ( sizeof ( $message_parser -> warn_msg ))
{
$error [] = implode ( '<br />' , $message_parser -> warn_msg );
$message_parser -> warn_msg = array ();
}
2006-09-13 16:08:36 +00:00
$message_parser -> parse ( $post_data [ 'enable_bbcode' ], ( $config [ 'allow_post_links' ]) ? $post_data [ 'enable_urls' ] : false , $post_data [ 'enable_smilies' ], $img_status , $flash_status , $quote_status , $config [ 'allow_post_links' ]);
2006-09-28 15:04:59 +00:00
// On a refresh we do not care about message parsing errors
if ( sizeof ( $message_parser -> warn_msg ) && $refresh )
{
$message_parser -> warn_msg = array ();
}
2002-10-28 00:08:18 +00:00
}
2004-07-27 19:47:27 +00:00
else
{
2006-05-12 20:52:58 +00:00
$message_parser -> bbcode_bitfield = $post_data [ 'bbcode_bitfield' ];
2004-07-27 19:47:27 +00:00
}
2002-10-28 00:08:18 +00:00
2003-11-27 23:44:59 +00:00
if ( $mode != 'edit' && ! $preview && ! $refresh && $config [ 'flood_interval' ] && ! $auth -> acl_get ( 'f_ignoreflood' , $forum_id ))
2002-10-28 00:08:18 +00:00
{
// Flood check
2003-11-30 17:45:13 +00:00
$last_post_time = 0 ;
2005-04-10 18:07:12 +00:00
if ( $user -> data [ 'is_registered' ])
2003-10-12 09:18:56 +00:00
{
2003-11-30 17:45:13 +00:00
$last_post_time = $user -> data [ 'user_lastpost_time' ];
2003-10-12 09:18:56 +00:00
}
else
{
2003-11-27 23:44:59 +00:00
$sql = ' SELECT post_time AS last_post_time
FROM ' . POSTS_TABLE . "
WHERE poster_ip = '" . $user->ip . "'
AND post_time > " . ( $current_time - $config['flood_interval'] );
2003-11-30 17:45:13 +00:00
$result = $db -> sql_query_limit ( $sql , 1 );
if ( $row = $db -> sql_fetchrow ( $result ))
{
$last_post_time = $row [ 'last_post_time' ];
}
2004-05-02 13:06:57 +00:00
$db -> sql_freeresult ( $result );
2003-10-12 09:18:56 +00:00
}
2002-10-28 00:08:18 +00:00
2006-05-12 20:52:58 +00:00
if ( $last_post_time && ( $current_time - $last_post_time ) < intval ( $config [ 'flood_interval' ]))
2002-10-28 00:08:18 +00:00
{
2006-05-12 20:52:58 +00:00
$error [] = $user -> lang [ 'FLOOD_ERROR' ];
2002-10-28 00:08:18 +00:00
}
}
// Validate username
2007-07-02 16:33:20 +00:00
if (( $post_data [ 'username' ] && ! $user -> data [ 'is_registered' ]) || ( $mode == 'edit' && $post_data [ 'poster_id' ] == ANONYMOUS && $post_data [ 'username' ] && $post_data [ 'post_username' ] && $post_data [ 'post_username' ] != $post_data [ 'username' ]))
2002-10-28 00:08:18 +00:00
{
2003-04-22 19:44:00 +00:00
include ( $phpbb_root_path . 'includes/functions_user.' . $phpEx );
2004-09-01 15:47:46 +00:00
2007-03-06 16:51:44 +00:00
if (( $result = validate_username ( $post_data [ 'username' ], ( ! empty ( $post_data [ 'post_username' ])) ? $post_data [ 'post_username' ] : '' )) !== false )
2002-10-28 00:08:18 +00:00
{
2006-10-06 18:43:55 +00:00
$user -> add_lang ( 'ucp' );
$error [] = $user -> lang [ $result . '_USERNAME' ];
2002-10-28 00:08:18 +00:00
}
}
2001-08-15 22:54:48 +00:00
2006-05-12 20:52:58 +00:00
if ( $config [ 'enable_post_confirm' ] && ! $user -> data [ 'is_registered' ] && in_array ( $mode , array ( 'quote' , 'post' , 'reply' )))
2006-03-28 12:44:27 +00:00
{
$confirm_id = request_var ( 'confirm_id' , '' );
$confirm_code = request_var ( 'confirm_code' , '' );
$sql = ' SELECT code
FROM ' . CONFIRM_TABLE . "
WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_type = " . CONFIRM_POST;
$result = $db -> sql_query ( $sql );
$confirm_row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
2006-06-06 20:53:46 +00:00
if ( empty ( $confirm_row [ 'code' ]) || strcasecmp ( $confirm_row [ 'code' ], $confirm_code ) !== 0 )
2006-03-28 12:44:27 +00:00
{
$error [] = $user -> lang [ 'CONFIRM_CODE_WRONG' ];
}
2006-10-06 21:37:17 +00:00
else
{
$solved_captcha = true ;
}
2006-03-28 12:44:27 +00:00
}
2007-10-03 15:05:54 +00:00
// check form
2007-12-05 14:18:37 +00:00
if (( $submit || $preview ) && ! check_form_key ( 'posting' ))
2007-10-03 15:05:54 +00:00
{
$error [] = $user -> lang [ 'FORM_INVALID' ];
}
2002-10-28 00:08:18 +00:00
// Parse subject
2008-01-05 16:10:10 +00:00
if ( ! $preview && ! $refresh && utf8_clean_string ( $post_data [ 'post_subject' ]) === '' && ( $mode == 'post' || ( $mode == 'edit' && $post_data [ 'topic_first_post_id' ] == $post_id )))
2002-10-28 00:08:18 +00:00
{
2003-06-23 14:00:57 +00:00
$error [] = $user -> lang [ 'EMPTY_SUBJECT' ];
2002-02-18 12:34:38 +00:00
}
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_last_vote' ] = ( isset ( $post_data [ 'poll_last_vote' ])) ? $post_data [ 'poll_last_vote' ] : 0 ;
2003-03-10 19:39:50 +00:00
2007-10-05 14:30:11 +00:00
if ( $post_data [ 'poll_option_text' ] &&
2007-06-16 12:25:36 +00:00
( $mode == 'post' || ( $mode == 'edit' && $post_id == $post_data [ 'topic_first_post_id' ] /* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/ ))
2004-09-05 15:45:50 +00:00
&& $auth -> acl_get ( 'f_poll' , $forum_id ))
{
$poll = array (
2006-05-12 20:52:58 +00:00
'poll_title' => $post_data [ 'poll_title' ],
'poll_length' => $post_data [ 'poll_length' ],
'poll_max_options' => $post_data [ 'poll_max_options' ],
'poll_option_text' => $post_data [ 'poll_option_text' ],
'poll_start' => $post_data [ 'poll_start' ],
'poll_last_vote' => $post_data [ 'poll_last_vote' ],
'poll_vote_change' => $post_data [ 'poll_vote_change' ],
'enable_bbcode' => $post_data [ 'enable_bbcode' ],
'enable_urls' => $post_data [ 'enable_urls' ],
'enable_smilies' => $post_data [ 'enable_smilies' ],
2004-09-05 15:45:50 +00:00
'img_status' => $img_status
);
2003-03-10 19:39:50 +00:00
2004-09-05 15:45:50 +00:00
$message_parser -> parse_poll ( $poll );
2006-06-06 20:53:46 +00:00
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_options' ] = ( isset ( $poll [ 'poll_options' ])) ? $poll [ 'poll_options' ] : '' ;
$post_data [ 'poll_title' ] = ( isset ( $poll [ 'poll_title' ])) ? $poll [ 'poll_title' ] : '' ;
2004-09-05 15:45:50 +00:00
2007-04-02 16:05:48 +00:00
/* We reset votes , therefore also allow removing options
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'poll_last_vote' ] && ( $poll [ 'poll_options_size' ] < $orig_poll_options_size ))
2004-09-05 15:45:50 +00:00
{
$message_parser -> warn_msg [] = $user -> lang [ 'NO_DELETE_POLL_OPTIONS' ];
2007-04-02 16:05:48 +00:00
} */
2004-09-05 15:45:50 +00:00
}
else
{
$poll = array ();
}
2002-10-30 00:57:27 +00:00
// Check topic type
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'topic_type' ] != POST_NORMAL && ( $mode == 'post' || ( $mode == 'edit' && $post_data [ 'topic_first_post_id' ] == $post_id )))
2002-10-30 00:57:27 +00:00
{
2006-05-12 20:52:58 +00:00
switch ( $post_data [ 'topic_type' ])
2002-10-30 00:57:27 +00:00
{
2003-05-05 22:48:17 +00:00
case POST_GLOBAL :
2003-02-26 19:53:10 +00:00
case POST_ANNOUNCE :
2003-06-23 14:00:57 +00:00
$auth_option = 'f_announce' ;
2006-01-22 13:06:13 +00:00
break ;
2003-02-26 19:53:10 +00:00
case POST_STICKY :
2003-06-23 14:00:57 +00:00
$auth_option = 'f_sticky' ;
2006-01-22 13:06:13 +00:00
break ;
2006-06-06 20:53:46 +00:00
2003-06-23 14:00:57 +00:00
default :
$auth_option = '' ;
2006-05-12 20:52:58 +00:00
break ;
2002-10-30 00:57:27 +00:00
}
2003-06-23 14:00:57 +00:00
if ( ! $auth -> acl_get ( $auth_option , $forum_id ))
2002-10-30 00:57:27 +00:00
{
2007-03-30 10:49:06 +00:00
// There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
// Another case would be a mod not having sticky permissions for example but edit permissions.
if ( $mode == 'edit' )
2007-01-17 18:41:49 +00:00
{
// To prevent non-authed users messing around with the topic type we reset it to the original one.
$post_data [ 'topic_type' ] = $post_data [ 'orig_topic_type' ];
}
else
{
$error [] = $user -> lang [ 'CANNOT_POST_' . str_replace ( 'F_' , '' , strtoupper ( $auth_option ))];
}
2002-10-30 00:57:27 +00:00
}
}
2006-09-28 15:04:59 +00:00
if ( sizeof ( $message_parser -> warn_msg ))
2003-06-29 10:59:36 +00:00
{
$error [] = implode ( '<br />' , $message_parser -> warn_msg );
}
2006-09-28 15:04:59 +00:00
// DNSBL check
if ( $config [ 'check_dnsbl' ] && ! $refresh )
{
2006-12-02 13:19:40 +00:00
if (( $dnsbl = $user -> check_dnsbl ( 'post' )) !== false )
2006-09-28 15:04:59 +00:00
{
$error [] = sprintf ( $user -> lang [ 'IP_BLACKLISTED' ], $user -> ip , $dnsbl [ 1 ]);
}
}
2002-10-28 20:39:06 +00:00
// Store message, sync counters
2003-06-23 14:00:57 +00:00
if ( ! sizeof ( $error ) && $submit )
2002-10-28 00:08:18 +00:00
{
2003-08-30 12:21:31 +00:00
// Check if we want to de-globalize the topic... and ask for new forum
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'topic_type' ] != POST_GLOBAL )
2003-04-12 14:30:21 +00:00
{
2003-08-30 12:59:29 +00:00
$sql = ' SELECT topic_type , forum_id
2003-08-30 12:21:31 +00:00
FROM ' . TOPICS_TABLE . "
WHERE topic_id = $topic_id " ;
2007-05-26 16:38:33 +00:00
$result = $db -> sql_query ( $sql );
2003-08-30 12:21:31 +00:00
$row = $db -> sql_fetchrow ( $result );
2006-05-12 20:52:58 +00:00
$db -> sql_freeresult ( $result );
2004-09-01 15:47:46 +00:00
2004-01-25 14:30:15 +00:00
if ( $row && ! $row [ 'forum_id' ] && $row [ 'topic_type' ] == POST_GLOBAL )
2003-08-30 12:21:31 +00:00
{
2003-10-09 14:48:55 +00:00
$to_forum_id = request_var ( 'to_forum_id' , 0 );
2004-09-01 15:47:46 +00:00
2007-05-26 16:38:33 +00:00
if ( $to_forum_id )
{
$sql = ' SELECT forum_type
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $to_forum_id ;
$result = $db -> sql_query ( $sql );
$forum_type = ( int ) $db -> sql_fetchfield ( 'forum_type' );
$db -> sql_freeresult ( $result );
if ( $forum_type != FORUM_POST || ! $auth -> acl_get ( 'f_post' , $to_forum_id ))
{
$to_forum_id = 0 ;
}
}
2003-08-30 12:21:31 +00:00
if ( ! $to_forum_id )
{
2006-03-15 13:03:57 +00:00
include_once ( $phpbb_root_path . 'includes/functions_admin.' . $phpEx );
2003-08-30 12:21:31 +00:00
$template -> assign_vars ( array (
2007-03-08 15:49:13 +00:00
'S_FORUM_SELECT' => make_forum_select ( false , false , false , true , true , true ),
2004-09-01 15:47:46 +00:00
'S_UNGLOBALISE' => true )
2003-08-30 12:21:31 +00:00
);
2004-09-01 15:47:46 +00:00
2004-01-25 14:30:15 +00:00
$submit = false ;
$refresh = true ;
2003-08-30 12:21:31 +00:00
}
else
{
2007-03-08 15:49:13 +00:00
if ( ! $auth -> acl_get ( 'f_post' , $to_forum_id ))
{
// This will only be triggered if the user tried to trick the forum.
2007-03-30 14:24:55 +00:00
trigger_error ( 'NOT_AUTHORISED' );
2007-03-08 15:49:13 +00:00
}
2003-08-30 12:21:31 +00:00
$forum_id = $to_forum_id ;
}
}
2003-04-12 14:30:21 +00:00
}
2003-08-30 12:21:31 +00:00
if ( $submit )
2003-04-12 14:30:21 +00:00
{
2003-08-30 12:21:31 +00:00
// Lock/Unlock Topic
2006-05-12 20:52:58 +00:00
$change_topic_status = $post_data [ 'topic_status' ];
2006-08-25 15:15:53 +00:00
$perm_lock_unlock = ( $auth -> acl_get ( 'm_lock' , $forum_id ) || ( $auth -> acl_get ( 'f_user_lock' , $forum_id ) && $user -> data [ 'is_registered' ] && ! empty ( $post_data [ 'topic_poster' ]) && $user -> data [ 'user_id' ] == $post_data [ 'topic_poster' ] && $post_data [ 'topic_status' ] == ITEM_UNLOCKED )) ? true : false ;
2003-04-12 14:30:21 +00:00
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'topic_status' ] == ITEM_LOCKED && ! $topic_lock && $perm_lock_unlock )
2003-08-30 12:21:31 +00:00
{
$change_topic_status = ITEM_UNLOCKED ;
}
2006-05-12 20:52:58 +00:00
else if ( $post_data [ 'topic_status' ] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock )
2003-08-30 12:21:31 +00:00
{
$change_topic_status = ITEM_LOCKED ;
}
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
if ( $change_topic_status != $post_data [ 'topic_status' ])
2003-08-30 12:21:31 +00:00
{
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_status = $change_topic_status
WHERE topic_id = $topic_id
AND topic_moved_id = 0 " ;
$db -> sql_query ( $sql );
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
$user_lock = ( $auth -> acl_get ( 'f_user_lock' , $forum_id ) && $user -> data [ 'is_registered' ] && $user -> data [ 'user_id' ] == $post_data [ 'topic_poster' ]) ? 'USER_' : '' ;
2004-01-25 14:30:15 +00:00
2006-05-12 20:52:58 +00:00
add_log ( 'mod' , $forum_id , $topic_id , 'LOG_' . $user_lock . (( $change_topic_status == ITEM_LOCKED ) ? 'LOCK' : 'UNLOCK' ), $post_data [ 'topic_title' ]);
2003-08-30 12:21:31 +00:00
}
// Lock/Unlock Post Edit
2006-05-12 20:52:58 +00:00
if ( $mode == 'edit' && $post_data [ 'post_edit_locked' ] == ITEM_LOCKED && ! $post_lock && $auth -> acl_get ( 'm_edit' , $forum_id ))
2003-08-30 12:21:31 +00:00
{
2006-05-12 20:52:58 +00:00
$post_data [ 'post_edit_locked' ] = ITEM_UNLOCKED ;
2003-08-30 12:21:31 +00:00
}
2006-05-12 20:52:58 +00:00
else if ( $mode == 'edit' && $post_data [ 'post_edit_locked' ] == ITEM_UNLOCKED && $post_lock && $auth -> acl_get ( 'm_edit' , $forum_id ))
2003-08-30 12:21:31 +00:00
{
2006-05-12 20:52:58 +00:00
$post_data [ 'post_edit_locked' ] = ITEM_LOCKED ;
2003-08-30 12:21:31 +00:00
}
2006-05-12 20:52:58 +00:00
$data = array (
2006-05-17 16:58:56 +00:00
'topic_title' => ( empty ( $post_data [ 'topic_title' ])) ? $post_data [ 'post_subject' ] : $post_data [ 'topic_title' ],
2006-05-12 20:52:58 +00:00
'topic_first_post_id' => ( isset ( $post_data [ 'topic_first_post_id' ])) ? ( int ) $post_data [ 'topic_first_post_id' ] : 0 ,
'topic_last_post_id' => ( isset ( $post_data [ 'topic_last_post_id' ])) ? ( int ) $post_data [ 'topic_last_post_id' ] : 0 ,
'topic_time_limit' => ( int ) $post_data [ 'topic_time_limit' ],
2007-03-03 17:41:21 +00:00
'topic_attachment' => ( isset ( $post_data [ 'topic_attachment' ])) ? ( int ) $post_data [ 'topic_attachment' ] : 0 ,
2003-10-10 15:02:48 +00:00
'post_id' => ( int ) $post_id ,
'topic_id' => ( int ) $topic_id ,
'forum_id' => ( int ) $forum_id ,
2006-05-12 20:52:58 +00:00
'icon_id' => ( int ) $post_data [ 'icon_id' ],
'poster_id' => ( int ) $post_data [ 'poster_id' ],
'enable_sig' => ( bool ) $post_data [ 'enable_sig' ],
'enable_bbcode' => ( bool ) $post_data [ 'enable_bbcode' ],
'enable_smilies' => ( bool ) $post_data [ 'enable_smilies' ],
'enable_urls' => ( bool ) $post_data [ 'enable_urls' ],
'enable_indexing' => ( bool ) $post_data [ 'enable_indexing' ],
2004-05-26 18:20:33 +00:00
'message_md5' => ( string ) $message_md5 ,
2006-05-12 20:52:58 +00:00
'post_time' => ( isset ( $post_data [ 'post_time' ])) ? ( int ) $post_data [ 'post_time' ] : $current_time ,
'post_checksum' => ( isset ( $post_data [ 'post_checksum' ])) ? ( string ) $post_data [ 'post_checksum' ] : '' ,
'post_edit_reason' => $post_data [ 'post_edit_reason' ],
'post_edit_user' => ( $mode == 'edit' ) ? $user -> data [ 'user_id' ] : (( isset ( $post_data [ 'post_edit_user' ])) ? ( int ) $post_data [ 'post_edit_user' ] : 0 ),
'forum_parents' => $post_data [ 'forum_parents' ],
'forum_name' => $post_data [ 'forum_name' ],
2003-08-30 12:21:31 +00:00
'notify' => $notify ,
2006-05-12 20:52:58 +00:00
'notify_set' => $post_data [ 'notify_set' ],
'poster_ip' => ( isset ( $post_data [ 'poster_ip' ])) ? $post_data [ 'poster_ip' ] : $user -> ip ,
'post_edit_locked' => ( int ) $post_data [ 'post_edit_locked' ],
2006-07-24 10:08:36 +00:00
'bbcode_bitfield' => $message_parser -> bbcode_bitfield ,
2004-09-04 19:32:23 +00:00
'bbcode_uid' => $message_parser -> bbcode_uid ,
'message' => $message_parser -> message ,
'attachment_data' => $message_parser -> attachment_data ,
2007-05-09 19:06:06 +00:00
'filename_data' => $message_parser -> filename_data ,
'topic_approved' => ( isset ( $post_data [ 'topic_approved' ])) ? $post_data [ 'topic_approved' ] : false ,
'post_approved' => ( isset ( $post_data [ 'post_approved' ])) ? $post_data [ 'post_approved' ] : false ,
2003-08-30 12:21:31 +00:00
);
2007-05-11 23:29:59 +00:00
if ( $mode == 'edit' )
{
$data [ 'topic_replies_real' ] = $post_data [ 'topic_replies_real' ];
2007-07-04 12:38:14 +00:00
$data [ 'topic_replies' ] = $post_data [ 'topic_replies' ];
2007-05-11 23:29:59 +00:00
}
2006-05-17 16:58:56 +00:00
$redirect_url = submit_post ( $mode , $post_data [ 'post_subject' ], $post_data [ 'username' ], $post_data [ 'topic_type' ], $poll , $data , $update_message );
2006-05-12 20:52:58 +00:00
2008-09-02 06:36:24 +00:00
// 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.
if (( $config [ 'enable_queue_trigger' ] && $user -> data [ 'user_posts' ] < $config [ 'queue_trigger_posts' ] && ! $auth -> acl_get ( 'm_approve' , $data [ 'forum_id' ])) || ! $auth -> acl_get ( 'f_noapprove' , $data [ 'forum_id' ]))
2007-06-11 00:12:42 +00:00
{
meta_refresh ( 10 , $redirect_url );
$message = ( $mode == 'edit' ) ? $user -> lang [ 'POST_EDITED_MOD' ] : $user -> lang [ 'POST_STORED_MOD' ];
2007-07-15 12:09:54 +00:00
$message .= (( $user -> data [ 'user_id' ] == ANONYMOUS ) ? '' : ' ' . $user -> lang [ 'POST_APPROVAL_NOTIFY' ]);
2007-06-11 00:12:42 +00:00
}
else
{
meta_refresh ( 3 , $redirect_url );
$message = ( $mode == 'edit' ) ? 'POST_EDITED' : 'POST_STORED' ;
$message = $user -> lang [ $message ] . '<br /><br />' . sprintf ( $user -> lang [ 'VIEW_MESSAGE' ], '<a href="' . $redirect_url . '">' , '</a>' );
}
2006-05-12 20:52:58 +00:00
2006-06-06 20:53:46 +00:00
$message .= '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_FORUM' ], '<a href="' . append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , 'f=' . $data [ 'forum_id' ]) . '">' , '</a>' );
2006-05-12 20:52:58 +00:00
trigger_error ( $message );
2003-08-30 12:21:31 +00:00
}
2004-09-01 15:47:46 +00:00
}
2003-02-27 23:37:02 +00:00
}
2002-10-28 00:08:18 +00:00
2003-06-17 19:34:17 +00:00
// Preview
2003-06-23 14:00:57 +00:00
if ( ! sizeof ( $error ) && $preview )
2003-02-27 23:37:02 +00:00
{
2006-05-12 20:52:58 +00:00
$post_data [ 'post_time' ] = ( $mode == 'edit' ) ? $post_data [ 'post_time' ] : $current_time ;
2003-04-11 00:19:29 +00:00
2006-05-12 20:52:58 +00:00
$preview_message = $message_parser -> format_display ( $post_data [ 'enable_bbcode' ], $post_data [ 'enable_urls' ], $post_data [ 'enable_smilies' ], false );
2003-06-23 14:00:57 +00:00
2006-05-12 20:52:58 +00:00
$preview_signature = ( $mode == 'edit' ) ? $post_data [ 'user_sig' ] : $user -> data [ 'user_sig' ];
$preview_signature_uid = ( $mode == 'edit' ) ? $post_data [ 'user_sig_bbcode_uid' ] : $user -> data [ 'user_sig_bbcode_uid' ];
$preview_signature_bitfield = ( $mode == 'edit' ) ? $post_data [ 'user_sig_bbcode_bitfield' ] : $user -> data [ 'user_sig_bbcode_bitfield' ];
2003-06-23 14:00:57 +00:00
2004-09-04 19:32:23 +00:00
// Signature
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'enable_sig' ] && $config [ 'allow_sig' ] && $preview_signature && $auth -> acl_get ( 'f_sigs' , $forum_id ))
2004-09-04 19:32:23 +00:00
{
$parse_sig = new parse_message ( $preview_signature );
$parse_sig -> bbcode_uid = $preview_signature_uid ;
$parse_sig -> bbcode_bitfield = $preview_signature_bitfield ;
// Not sure about parameters for bbcode/smilies/urls... in signatures
2006-05-12 20:52:58 +00:00
$parse_sig -> format_display ( $config [ 'allow_sig_bbcode' ], true , $config [ 'allow_sig_smilies' ]);
2004-09-04 19:32:23 +00:00
$preview_signature = $parse_sig -> message ;
unset ( $parse_sig );
}
else
{
$preview_signature = '' ;
}
2006-06-06 20:53:46 +00:00
2006-05-17 16:58:56 +00:00
$preview_subject = censor_text ( $post_data [ 'post_subject' ]);
2006-06-06 20:53:46 +00:00
2003-03-10 19:39:50 +00:00
// Poll Preview
2007-06-16 12:25:36 +00:00
if ( ! $poll_delete && ( $mode == 'post' || ( $mode == 'edit' && $post_id == $post_data [ 'topic_first_post_id' ] /* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/ ))
2004-09-05 15:45:50 +00:00
&& $auth -> acl_get ( 'f_poll' , $forum_id ))
2003-02-27 23:37:02 +00:00
{
2006-05-12 20:52:58 +00:00
$parse_poll = new parse_message ( $post_data [ 'poll_title' ]);
2004-09-05 15:45:50 +00:00
$parse_poll -> bbcode_uid = $message_parser -> bbcode_uid ;
$parse_poll -> bbcode_bitfield = $message_parser -> bbcode_bitfield ;
2006-05-12 20:52:58 +00:00
$parse_poll -> format_display ( $post_data [ 'enable_bbcode' ], $post_data [ 'enable_urls' ], $post_data [ 'enable_smilies' ]);
2006-06-06 20:53:46 +00:00
2007-06-11 00:12:42 +00:00
if ( $post_data [ 'poll_length' ])
{
$poll_end = ( $post_data [ 'poll_length' ] * 86400 ) + (( $post_data [ 'poll_start' ]) ? $post_data [ 'poll_start' ] : time ());
}
2003-03-10 19:39:50 +00:00
$template -> assign_vars ( array (
2006-06-06 20:53:46 +00:00
'S_HAS_POLL_OPTIONS' => ( sizeof ( $post_data [ 'poll_options' ])),
'S_IS_MULTI_CHOICE' => ( $post_data [ 'poll_max_options' ] > 1 ) ? true : false ,
2004-09-05 15:45:50 +00:00
'POLL_QUESTION' => $parse_poll -> message ,
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
2007-06-11 00:12:42 +00:00
'L_POLL_LENGTH' => ( $post_data [ 'poll_length' ]) ? sprintf ( $user -> lang [ 'POLL_RUN_TILL' ], $user -> format_date ( $poll_end )) : '' ,
2006-05-12 20:52:58 +00:00
'L_MAX_VOTES' => ( $post_data [ 'poll_max_options' ] == 1 ) ? $user -> lang [ 'MAX_OPTION_SELECT' ] : sprintf ( $user -> lang [ 'MAX_OPTIONS_SELECT' ], $post_data [ 'poll_max_options' ]))
2003-03-10 19:39:50 +00:00
);
2006-05-12 20:52:58 +00:00
$parse_poll -> message = implode ( " \n " , $post_data [ 'poll_options' ]);
$parse_poll -> format_display ( $post_data [ 'enable_bbcode' ], $post_data [ 'enable_urls' ], $post_data [ 'enable_smilies' ]);
2004-09-05 15:45:50 +00:00
$preview_poll_options = explode ( '<br />' , $parse_poll -> message );
unset ( $parse_poll );
2007-07-21 16:11:09 +00:00
foreach ( $preview_poll_options as $key => $option )
2003-03-10 19:39:50 +00:00
{
2006-06-06 20:53:46 +00:00
$template -> assign_block_vars ( 'poll_option' , array (
2007-07-21 16:11:09 +00:00
'POLL_OPTION_CAPTION' => $option ,
'POLL_OPTION_ID' => $key + 1 )
2006-06-06 20:53:46 +00:00
);
2003-03-10 19:39:50 +00:00
}
2004-09-05 15:45:50 +00:00
unset ( $preview_poll_options );
2003-02-27 23:37:02 +00:00
}
2003-06-17 19:34:17 +00:00
// Attachment Preview
if ( sizeof ( $message_parser -> attachment_data ))
{
2004-01-25 14:30:15 +00:00
$template -> assign_var ( 'S_HAS_ATTACHMENTS' , true );
2004-09-16 18:33:22 +00:00
2006-12-24 13:11:54 +00:00
$update_count = array ();
2004-09-16 18:33:22 +00:00
$attachment_data = $message_parser -> attachment_data ;
2006-12-24 13:11:54 +00:00
parse_attachments ( $forum_id , $preview_message , $attachment_data , $update_count , true );
2004-09-16 18:33:22 +00:00
foreach ( $attachment_data as $i => $attachment )
{
$template -> assign_block_vars ( 'attachment' , array (
'DISPLAY_ATTACHMENT' => $attachment )
);
}
2006-12-24 13:11:54 +00:00
unset ( $attachment_data );
2003-06-17 19:34:17 +00:00
}
2001-12-16 18:13:34 +00:00
2004-09-04 19:32:23 +00:00
if ( ! sizeof ( $error ))
{
$template -> assign_vars ( array (
'PREVIEW_SUBJECT' => $preview_subject ,
'PREVIEW_MESSAGE' => $preview_message ,
'PREVIEW_SIGNATURE' => $preview_signature ,
2003-06-23 14:00:57 +00:00
2004-09-04 19:32:23 +00:00
'S_DISPLAY_PREVIEW' => true )
);
}
2003-04-16 21:16:57 +00:00
}
2003-03-10 19:39:50 +00:00
2004-09-04 19:32:23 +00:00
// Decode text for message display
2006-05-12 20:52:58 +00:00
$post_data [ 'bbcode_uid' ] = ( $mode == 'quote' && ! $preview && ! $refresh && ! sizeof ( $error )) ? $post_data [ 'bbcode_uid' ] : $message_parser -> bbcode_uid ;
$message_parser -> decode_message ( $post_data [ 'bbcode_uid' ]);
2003-06-23 14:00:57 +00:00
2006-06-08 10:59:36 +00:00
if ( $mode == 'quote' && ! $submit && ! $preview && ! $refresh )
2003-02-27 23:37:02 +00:00
{
2007-11-17 20:04:49 +00:00
$message_parser -> message = '[quote="' . $post_data [ 'quote_username' ] . '"]' . censor_text ( trim ( $message_parser -> message )) . " [/quote] \n " ;
2003-02-27 23:37:02 +00:00
}
2001-08-10 22:00:12 +00:00
2006-06-08 10:59:36 +00:00
if (( $mode == 'reply' || $mode == 'quote' ) && ! $submit && ! $preview && ! $refresh )
2003-03-10 19:39:50 +00:00
{
2007-04-13 15:33:22 +00:00
$post_data [ 'post_subject' ] = (( strpos ( $post_data [ 'post_subject' ], 'Re: ' ) !== 0 ) ? 'Re: ' : '' ) . censor_text ( $post_data [ 'post_subject' ]);
2003-03-10 19:39:50 +00:00
}
2004-09-04 19:32:23 +00:00
$attachment_data = $message_parser -> attachment_data ;
$filename_data = $message_parser -> filename_data ;
2006-05-12 20:52:58 +00:00
$post_data [ 'post_text' ] = $message_parser -> message ;
2004-09-05 15:45:50 +00:00
2006-05-12 20:52:58 +00:00
if ( sizeof ( $post_data [ 'poll_options' ]) && $post_data [ 'poll_title' ])
2004-09-05 15:45:50 +00:00
{
2006-05-12 20:52:58 +00:00
$message_parser -> message = $post_data [ 'poll_title' ];
$message_parser -> bbcode_uid = $post_data [ 'bbcode_uid' ];
2004-09-05 15:45:50 +00:00
$message_parser -> decode_message ();
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_title' ] = $message_parser -> message ;
2004-09-05 15:45:50 +00:00
2006-05-12 20:52:58 +00:00
$message_parser -> message = implode ( " \n " , $post_data [ 'poll_options' ]);
2004-09-05 15:45:50 +00:00
$message_parser -> decode_message ();
2006-05-12 20:52:58 +00:00
$post_data [ 'poll_options' ] = explode ( " \n " , $message_parser -> message );
2004-09-05 15:45:50 +00:00
}
2003-06-23 14:00:57 +00:00
2002-10-04 13:09:10 +00:00
// MAIN POSTING PAGE BEGINS HERE
2002-11-07 22:02:49 +00:00
// Forum moderators?
2006-05-12 20:52:58 +00:00
$moderators = array ();
2003-02-27 23:37:02 +00:00
get_moderators ( $moderators , $forum_id );
2001-06-13 17:36:58 +00:00
2005-03-21 22:43:07 +00:00
// Generate smiley listing
2003-10-10 12:11:18 +00:00
generate_smilies ( 'inline' , $forum_id );
2001-08-10 22:00:12 +00:00
2004-02-08 18:02:17 +00:00
// Generate inline attachment select box
2004-09-04 19:32:23 +00:00
posting_gen_inline_attachments ( $attachment_data );
2004-02-08 18:02:17 +00:00
2004-09-01 08:40:54 +00:00
// Do show topic type selection only in first post.
$topic_type_toggle = false ;
2004-06-24 08:09:00 +00:00
2006-05-12 20:52:58 +00:00
if ( $mode == 'post' || ( $mode == 'edit' && $post_id == $post_data [ 'topic_first_post_id' ]))
2001-06-13 17:36:58 +00:00
{
2006-05-12 20:52:58 +00:00
$topic_type_toggle = posting_gen_topic_types ( $forum_id , $post_data [ 'topic_type' ]);
2001-06-13 17:36:58 +00:00
}
2001-04-17 07:14:50 +00:00
2004-09-01 08:40:54 +00:00
$s_topic_icons = false ;
2007-05-06 19:11:06 +00:00
if ( $post_data [ 'enable_icons' ] && $auth -> acl_get ( 'f_icons' , $forum_id ))
2004-09-01 08:40:54 +00:00
{
2006-05-12 20:52:58 +00:00
$s_topic_icons = posting_gen_topic_icons ( $mode , $post_data [ 'icon_id' ]);
2004-09-01 08:40:54 +00:00
}
2004-05-02 13:06:57 +00:00
2006-05-12 20:52:58 +00:00
$bbcode_checked = ( isset ( $post_data [ 'enable_bbcode' ])) ? ! $post_data [ 'enable_bbcode' ] : (( $config [ 'allow_bbcode' ]) ? ! $user -> optionget ( 'bbcode' ) : 1 );
$smilies_checked = ( isset ( $post_data [ 'enable_smilies' ])) ? ! $post_data [ 'enable_smilies' ] : (( $config [ 'allow_smilies' ]) ? ! $user -> optionget ( 'smilies' ) : 1 );
$urls_checked = ( isset ( $post_data [ 'enable_urls' ])) ? ! $post_data [ 'enable_urls' ] : 0 ;
$sig_checked = $post_data [ 'enable_sig' ];
2007-10-04 18:26:52 +00:00
$lock_topic_checked = ( isset ( $topic_lock ) && $topic_lock ) ? $topic_lock : (( $post_data [ 'topic_status' ] == ITEM_LOCKED ) ? 1 : 0 );
2006-05-12 20:52:58 +00:00
$lock_post_checked = ( isset ( $post_lock )) ? $post_lock : $post_data [ 'post_edit_locked' ];
2006-10-26 10:58:58 +00:00
// If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting
$notify_set = ( $mode != 'edit' && $config [ 'allow_topic_notify' ] && $user -> data [ 'is_registered' ] && ! $post_data [ 'notify_set' ]) ? $user -> data [ 'user_notify' ] : $post_data [ 'notify_set' ];
$notify_checked = ( isset ( $notify )) ? $notify : (( $mode == 'post' ) ? $user -> data [ 'user_notify' ] : $notify_set );
2002-10-04 13:09:10 +00:00
2003-01-20 05:12:38 +00:00
// Page title & action URL, include session_id for security purpose
2006-06-06 20:53:46 +00:00
$s_action = append_sid ( " { $phpbb_root_path } posting. $phpEx " , " mode= $mode &f= $forum_id " , true , $user -> session_id );
2003-06-17 19:34:17 +00:00
$s_action .= ( $topic_id ) ? " &t= $topic_id " : '' ;
$s_action .= ( $post_id ) ? " &p= $post_id " : '' ;
2003-02-28 12:57:10 +00:00
2003-01-22 16:35:06 +00:00
switch ( $mode )
2001-08-10 22:00:12 +00:00
{
2002-10-28 00:08:18 +00:00
case 'post' :
2002-11-09 00:47:14 +00:00
$page_title = $user -> lang [ 'POST_TOPIC' ];
2006-01-22 13:06:13 +00:00
break ;
2001-08-09 22:21:55 +00:00
2003-02-26 19:53:10 +00:00
case 'quote' :
2001-09-06 00:29:07 +00:00
case 'reply' :
2002-11-09 00:47:14 +00:00
$page_title = $user -> lang [ 'POST_REPLY' ];
2006-01-22 13:06:13 +00:00
break ;
2001-09-06 00:29:07 +00:00
2003-02-28 12:57:10 +00:00
case 'delete' :
2002-10-28 00:08:18 +00:00
case 'edit' :
2002-11-18 21:04:45 +00:00
$page_title = $user -> lang [ 'EDIT_POST' ];
2006-05-12 20:52:58 +00:00
break ;
2001-08-10 22:00:12 +00:00
}
2001-08-09 22:21:55 +00:00
2004-05-31 18:00:10 +00:00
// Build Navigation Links
2006-05-12 20:52:58 +00:00
generate_forum_nav ( $post_data );
2003-01-22 16:35:06 +00:00
2004-05-31 18:00:10 +00:00
// Build Forum Rules
2006-05-12 20:52:58 +00:00
generate_forum_rules ( $post_data );
2004-05-30 19:24:53 +00:00
2006-11-18 16:27:35 +00:00
if ( $config [ 'enable_post_confirm' ] && ! $user -> data [ 'is_registered' ] && $solved_captcha === false && ( $mode == 'post' || $mode == 'reply' || $mode == 'quote' ))
2006-03-28 12:44:27 +00:00
{
// Show confirm image
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
AND confirm_type = " . CONFIRM_POST;
$db -> sql_query ( $sql );
// Generate code
2006-11-18 16:27:35 +00:00
$code = gen_rand_string ( mt_rand ( 5 , 8 ));
$confirm_id = md5 ( unique_id ( $user -> ip ));
2006-12-03 17:36:59 +00:00
$seed = hexdec ( substr ( unique_id (), 4 , 10 ));
2006-11-18 16:27:35 +00:00
2006-12-09 19:17:01 +00:00
// compute $seed % 0x7fffffff
$seed -= 0x7fffffff * floor ( $seed / 0x7fffffff );
2006-12-08 00:08:46 +00:00
2006-11-18 16:27:35 +00:00
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db -> sql_build_array ( 'INSERT' , array (
'confirm_id' => ( string ) $confirm_id ,
'session_id' => ( string ) $user -> session_id ,
'confirm_type' => ( int ) CONFIRM_POST ,
2006-12-03 17:36:59 +00:00
'code' => ( string ) $code ,
2006-12-08 00:08:46 +00:00
'seed' => ( int ) $seed )
2006-11-18 16:27:35 +00:00
);
$db -> sql_query ( $sql );
2006-03-28 12:44:27 +00:00
2006-11-18 16:27:35 +00:00
$template -> assign_vars ( array (
'S_CONFIRM_CODE' => true ,
'CONFIRM_ID' => $confirm_id ,
'CONFIRM_IMAGE' => '<img src="' . append_sid ( " { $phpbb_root_path } ucp. $phpEx " , 'mode=confirm&id=' . $confirm_id . '&type=' . CONFIRM_POST ) . '" alt="" title="" />' ,
'L_POST_CONFIRM_EXPLAIN' => sprintf ( $user -> lang [ 'POST_CONFIRM_EXPLAIN' ], '<a href="mailto:' . htmlspecialchars ( $config [ 'board_contact' ]) . '">' , '</a>' ),
));
2006-03-28 12:44:27 +00:00
}
2006-05-12 20:52:58 +00:00
$s_hidden_fields = ( $mode == 'reply' || $mode == 'quote' ) ? '<input type="hidden" name="topic_cur_post_id" value="' . $post_data [ 'topic_last_post_id' ] . '" />' : '' ;
2003-10-22 20:41:00 +00:00
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />' ;
2006-05-12 20:52:58 +00:00
$s_hidden_fields .= ( $draft_id || isset ( $_REQUEST [ 'draft_loaded' ])) ? '<input type="hidden" name="draft_loaded" value="' . request_var ( 'draft_loaded' , $draft_id ) . '" />' : '' ;
2003-03-10 19:39:50 +00:00
2006-11-18 16:27:35 +00:00
// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
if ( $solved_captcha !== false )
{
$s_hidden_fields .= build_hidden_fields ( array (
'confirm_id' => request_var ( 'confirm_id' , '' ),
'confirm_code' => request_var ( 'confirm_code' , '' ))
);
}
2008-09-18 15:05:51 +00:00
$form_enctype = ( @ ini_get ( 'file_uploads' ) == '0' || strtolower ( @ ini_get ( 'file_uploads' )) == 'off' || ! $config [ 'allow_attachments' ] || ! $auth -> acl_get ( 'u_attach' ) || ! $auth -> acl_get ( 'f_attach' , $forum_id )) ? '' : ' enctype="multipart/form-data"' ;
2007-10-03 15:05:54 +00:00
add_form_key ( 'posting' );
2003-03-10 19:39:50 +00:00
2002-10-04 13:09:10 +00:00
// Start assigning vars for main posting page ...
2002-02-18 12:34:38 +00:00
$template -> assign_vars ( array (
2006-06-06 20:53:46 +00:00
'L_POST_A' => $page_title ,
'L_ICON' => ( $mode == 'reply' || $mode == 'quote' || ( $mode == 'edit' && $post_id != $post_data [ 'topic_first_post_id' ])) ? $user -> lang [ 'POST_ICON' ] : $user -> lang [ 'TOPIC_ICON' ],
'L_MESSAGE_BODY_EXPLAIN' => ( intval ( $config [ 'max_post_chars' ])) ? sprintf ( $user -> lang [ 'MESSAGE_BODY_EXPLAIN' ], intval ( $config [ 'max_post_chars' ])) : '' ,
2002-10-28 00:08:18 +00:00
2006-06-06 20:53:46 +00:00
'FORUM_NAME' => $post_data [ 'forum_name' ],
2006-07-17 03:23:31 +00:00
'FORUM_DESC' => ( $post_data [ 'forum_desc' ]) ? generate_text_for_display ( $post_data [ 'forum_desc' ], $post_data [ 'forum_desc_uid' ], $post_data [ 'forum_desc_bitfield' ], $post_data [ 'forum_desc_options' ]) : '' ,
2006-07-01 19:11:52 +00:00
'TOPIC_TITLE' => censor_text ( $post_data [ 'topic_title' ]),
2006-06-06 20:53:46 +00:00
'MODERATORS' => ( sizeof ( $moderators )) ? implode ( ', ' , $moderators [ $forum_id ]) : '' ,
2006-05-12 20:52:58 +00:00
'USERNAME' => (( ! $preview && $mode != 'quote' ) || $preview ) ? $post_data [ 'username' ] : '' ,
'SUBJECT' => $post_data [ 'post_subject' ],
'MESSAGE' => $post_data [ 'post_text' ],
2006-09-13 16:08:36 +00:00
'BBCODE_STATUS' => ( $bbcode_status ) ? sprintf ( $user -> lang [ 'BBCODE_IS_ON' ], '<a href="' . append_sid ( " { $phpbb_root_path } faq. $phpEx " , 'mode=bbcode' ) . '">' , '</a>' ) : sprintf ( $user -> lang [ 'BBCODE_IS_OFF' ], '<a href="' . append_sid ( " { $phpbb_root_path } faq. $phpEx " , 'mode=bbcode' ) . '">' , '</a>' ),
2003-02-27 23:37:02 +00:00
'IMG_STATUS' => ( $img_status ) ? $user -> lang [ 'IMAGES_ARE_ON' ] : $user -> lang [ 'IMAGES_ARE_OFF' ],
'FLASH_STATUS' => ( $flash_status ) ? $user -> lang [ 'FLASH_IS_ON' ] : $user -> lang [ 'FLASH_IS_OFF' ],
'SMILIES_STATUS' => ( $smilies_status ) ? $user -> lang [ 'SMILIES_ARE_ON' ] : $user -> lang [ 'SMILIES_ARE_OFF' ],
2007-03-30 10:49:06 +00:00
'URL_STATUS' => ( $bbcode_status && $url_status ) ? $user -> lang [ 'URL_IS_ON' ] : $user -> lang [ 'URL_IS_OFF' ],
2006-08-05 15:49:28 +00:00
'MINI_POST_IMG' => $user -> img ( 'icon_post_target' , $user -> lang [ 'POST' ]),
2006-05-12 20:52:58 +00:00
'POST_DATE' => ( $post_data [ 'post_time' ]) ? $user -> format_date ( $post_data [ 'post_time' ]) : '' ,
2004-09-01 15:47:46 +00:00
'ERROR' => ( sizeof ( $error )) ? implode ( '<br />' , $error ) : '' ,
2006-05-12 20:52:58 +00:00
'TOPIC_TIME_LIMIT' => ( int ) $post_data [ 'topic_time_limit' ],
'EDIT_REASON' => $post_data [ 'post_edit_reason' ],
2006-06-06 20:53:46 +00:00
'U_VIEW_FORUM' => append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , " f= $forum_id " ),
2006-11-18 16:27:35 +00:00
'U_VIEW_TOPIC' => ( $mode != 'post' ) ? append_sid ( " { $phpbb_root_path } viewtopic. $phpEx " , " f= $forum_id &t= $topic_id " ) : '' ,
2006-06-06 20:53:46 +00:00
'U_PROGRESS_BAR' => append_sid ( " { $phpbb_root_path } posting. $phpEx " , " f= $forum_id &mode=popup " ),
2007-09-22 18:31:50 +00:00
'UA_PROGRESS_BAR' => addslashes ( append_sid ( " { $phpbb_root_path } posting. $phpEx " , " f= $forum_id &mode=popup " )),
2003-02-27 23:37:02 +00:00
2006-04-29 01:18:57 +00:00
'S_PRIVMSGS' => false ,
'S_CLOSE_PROGRESS_WINDOW' => ( isset ( $_POST [ 'add_file' ])) ? true : false ,
'S_EDIT_POST' => ( $mode == 'edit' ) ? true : false ,
'S_EDIT_REASON' => ( $mode == 'edit' && $auth -> acl_get ( 'm_edit' , $forum_id )) ? true : false ,
2007-03-06 16:51:44 +00:00
'S_DISPLAY_USERNAME' => ( ! $user -> data [ 'is_registered' ] || ( $mode == 'edit' && $post_data [ 'poster_id' ] == ANONYMOUS )) ? true : false ,
2006-05-12 20:52:58 +00:00
'S_SHOW_TOPIC_ICONS' => $s_topic_icons ,
2008-09-23 18:04:52 +00:00
'S_DELETE_ALLOWED' => ( $mode == 'edit' && (( $post_id == $post_data [ 'topic_last_post_id' ] && $post_data [ 'poster_id' ] == $user -> data [ 'user_id' ] && $auth -> acl_get ( 'f_delete' , $forum_id ) && ! $post_data [ 'post_edit_locked' ] && ( $post_data [ 'post_time' ] > time () - ( $config [ 'edit_time' ] * 60 ) || ! $config [ 'edit_time' ])) || $auth -> acl_get ( 'm_delete' , $forum_id ))) ? true : false ,
2006-05-12 20:52:58 +00:00
'S_BBCODE_ALLOWED' => $bbcode_status ,
2006-06-06 20:53:46 +00:00
'S_BBCODE_CHECKED' => ( $bbcode_checked ) ? ' checked="checked"' : '' ,
2006-05-12 20:52:58 +00:00
'S_SMILIES_ALLOWED' => $smilies_status ,
'S_SMILIES_CHECKED' => ( $smilies_checked ) ? ' checked="checked"' : '' ,
'S_SIG_ALLOWED' => ( $auth -> acl_get ( 'f_sigs' , $forum_id ) && $config [ 'allow_sig' ] && $user -> data [ 'is_registered' ]) ? true : false ,
'S_SIGNATURE_CHECKED' => ( $sig_checked ) ? ' checked="checked"' : '' ,
2007-06-08 15:38:39 +00:00
'S_NOTIFY_ALLOWED' => ( ! $user -> data [ 'is_registered' ] || ( $mode == 'edit' && $user -> data [ 'user_id' ] != $post_data [ 'poster_id' ]) || ! $config [ 'allow_topic_notify' ] || ! $config [ 'email_enable' ]) ? false : true ,
2006-06-06 20:53:46 +00:00
'S_NOTIFY_CHECKED' => ( $notify_checked ) ? ' checked="checked"' : '' ,
2006-08-25 15:15:53 +00:00
'S_LOCK_TOPIC_ALLOWED' => (( $mode == 'edit' || $mode == 'reply' || $mode == 'quote' ) && ( $auth -> acl_get ( 'm_lock' , $forum_id ) || ( $auth -> acl_get ( 'f_user_lock' , $forum_id ) && $user -> data [ 'is_registered' ] && ! empty ( $post_data [ 'topic_poster' ]) && $user -> data [ 'user_id' ] == $post_data [ 'topic_poster' ] && $post_data [ 'topic_status' ] == ITEM_UNLOCKED ))) ? true : false ,
2006-05-12 20:52:58 +00:00
'S_LOCK_TOPIC_CHECKED' => ( $lock_topic_checked ) ? ' checked="checked"' : '' ,
'S_LOCK_POST_ALLOWED' => ( $mode == 'edit' && $auth -> acl_get ( 'm_edit' , $forum_id )) ? true : false ,
'S_LOCK_POST_CHECKED' => ( $lock_post_checked ) ? ' checked="checked"' : '' ,
2006-09-13 16:08:36 +00:00
'S_LINKS_ALLOWED' => $url_status ,
2006-05-12 20:52:58 +00:00
'S_MAGIC_URL_CHECKED' => ( $urls_checked ) ? ' checked="checked"' : '' ,
'S_TYPE_TOGGLE' => $topic_type_toggle ,
#10005, #10003, #10001, #9999, #9945, #9965, #9909, #9906, #9877, #9861, #9831, #9830, #9815, #9665, #9624
prosilver adjustments for important announcements in ucp - #9995
MCP fixes for user notes/warnings - #9981
Preserving imageset values on save/edit
find a member link for Mass PM's - #9925
syndicate window.onload events where necessary - #9878
Duplicate topics in forums with announcements - #9840
Email template for forced re-activation - #9808
Topic pagination adjustment - #9763
Changed compose message layout in UCP - #9706, #9702
Fixed inline attachment font size (hopefully)
git-svn-id: file:///svn/phpbb/trunk@7384 89ea8834-ac86-4346-8a33-228a782c2dd0
2007-04-22 15:27:40 +00:00
'S_SAVE_ALLOWED' => ( $auth -> acl_get ( 'u_savedrafts' ) && $user -> data [ 'is_registered' ] && $mode != 'edit' ) ? true : false ,
2006-05-12 20:52:58 +00:00
'S_HAS_DRAFTS' => ( $auth -> acl_get ( 'u_savedrafts' ) && $user -> data [ 'is_registered' ] && $post_data [ 'drafts' ]) ? true : false ,
'S_FORM_ENCTYPE' => $form_enctype ,
2003-03-22 15:48:46 +00:00
2006-03-06 14:03:56 +00:00
'S_BBCODE_IMG' => $img_status ,
2006-09-13 16:08:36 +00:00
'S_BBCODE_URL' => $url_status ,
2006-03-06 14:03:56 +00:00
'S_BBCODE_FLASH' => $flash_status ,
'S_BBCODE_QUOTE' => $quote_status ,
2006-06-06 20:53:46 +00:00
'S_POST_ACTION' => $s_action ,
2003-03-10 19:39:50 +00:00
'S_HIDDEN_FIELDS' => $s_hidden_fields )
2001-06-13 17:36:58 +00:00
);
2006-03-06 14:03:56 +00:00
// Build custom bbcodes array
2006-07-06 16:46:53 +00:00
display_custom_bbcodes ();
2006-03-06 14:03:56 +00:00
2003-03-10 19:39:50 +00:00
// Poll entry
2007-06-16 12:25:36 +00:00
if (( $mode == 'post' || ( $mode == 'edit' && $post_id == $post_data [ 'topic_first_post_id' ] /* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/ ))
2004-09-05 15:45:50 +00:00
&& $auth -> acl_get ( 'f_poll' , $forum_id ))
2003-03-10 19:39:50 +00:00
{
$template -> assign_vars ( array (
2004-01-25 14:30:15 +00:00
'S_SHOW_POLL_BOX' => true ,
2004-09-05 15:45:50 +00:00
'S_POLL_VOTE_CHANGE' => ( $auth -> acl_get ( 'f_votechg' , $forum_id )),
2006-05-12 20:52:58 +00:00
'S_POLL_DELETE' => ( $mode == 'edit' && sizeof ( $post_data [ 'poll_options' ]) && (( ! $post_data [ 'poll_last_vote' ] && $post_data [ 'poster_id' ] == $user -> data [ 'user_id' ] && $auth -> acl_get ( 'f_delete' , $forum_id )) || $auth -> acl_get ( 'm_delete' , $forum_id ))),
2006-10-20 13:48:44 +00:00
'S_POLL_DELETE_CHECKED' => ( ! empty ( $poll_delete )) ? true : false ,
2003-03-10 19:39:50 +00:00
2007-06-16 12:25:36 +00:00
'L_POLL_OPTIONS_EXPLAIN' => sprintf ( $user -> lang [ 'POLL_OPTIONS_' . (( $mode == 'edit' ) ? 'EDIT_' : '' ) . 'EXPLAIN' ], $config [ 'max_poll_options' ]),
2003-03-10 19:39:50 +00:00
2006-05-12 20:52:58 +00:00
'VOTE_CHANGE_CHECKED' => ( ! empty ( $post_data [ 'poll_vote_change' ])) ? ' checked="checked"' : '' ,
2006-06-06 20:53:46 +00:00
'POLL_TITLE' => ( isset ( $post_data [ 'poll_title' ])) ? $post_data [ 'poll_title' ] : '' ,
2006-05-12 20:52:58 +00:00
'POLL_OPTIONS' => ( ! empty ( $post_data [ 'poll_options' ])) ? implode ( " \n " , $post_data [ 'poll_options' ]) : '' ,
'POLL_MAX_OPTIONS' => ( isset ( $post_data [ 'poll_max_options' ])) ? ( int ) $post_data [ 'poll_max_options' ] : 1 ,
2006-06-06 20:53:46 +00:00
'POLL_LENGTH' => $post_data [ 'poll_length' ])
2003-03-10 19:39:50 +00:00
);
}
2008-10-06 13:53:18 +00:00
// Show attachment box for adding attachments if true
$allowed = ( $auth -> acl_get ( 'f_attach' , $forum_id ) && $auth -> acl_get ( 'u_attach' ) && $config [ 'allow_attachments' ] && $form_enctype );
2003-03-22 15:48:46 +00:00
// Attachment entry
2008-10-06 13:53:18 +00:00
posting_gen_attachment_entry ( $attachment_data , $filename_data , $allowed );
2003-03-22 15:48:46 +00:00
2002-10-04 13:09:10 +00:00
// Output page ...
2003-05-03 23:58:45 +00:00
page_header ( $page_title );
2002-10-04 13:09:10 +00:00
$template -> set_filenames ( array (
2002-11-21 01:35:53 +00:00
'body' => 'posting_body.html' )
2002-10-04 13:09:10 +00:00
);
2006-06-06 20:53:46 +00:00
make_jumpbox ( append_sid ( " { $phpbb_root_path } viewforum. $phpEx " ));
2001-10-16 11:12:32 +00:00
2003-02-28 12:57:10 +00:00
// Topic review
if ( $mode == 'reply' || $mode == 'quote' )
{
2003-10-11 11:46:29 +00:00
if ( topic_review ( $topic_id , $forum_id ))
2003-10-09 16:55:56 +00:00
{
2004-01-25 14:30:15 +00:00
$template -> assign_var ( 'S_DISPLAY_REVIEW' , true );
2003-10-09 16:55:56 +00:00
}
2003-02-28 12:57:10 +00:00
}
2003-05-03 23:58:45 +00:00
page_footer ();
2001-06-13 17:36:58 +00:00
2005-04-09 12:26:45 +00:00
/**
2006-05-12 20:52:58 +00:00
* Show upload popup ( progress bar )
2005-04-09 12:26:45 +00:00
*/
2006-05-12 20:52:58 +00:00
function upload_popup ( $forum_style = 0 )
2003-09-07 15:49:03 +00:00
{
2006-05-12 20:52:58 +00:00
global $template , $user ;
2003-09-07 15:49:03 +00:00
2006-05-12 20:52:58 +00:00
( $forum_style ) ? $user -> setup ( 'posting' , $forum_style ) : $user -> setup ( 'posting' );
2003-09-07 15:49:03 +00:00
2006-07-17 15:32:46 +00:00
page_header ( $user -> lang [ 'PROGRESS_BAR' ]);
2003-09-07 15:49:03 +00:00
2006-05-12 20:52:58 +00:00
$template -> set_filenames ( array (
'popup' => 'posting_progress_bar.html' )
);
2003-10-11 11:46:29 +00:00
2006-05-12 20:52:58 +00:00
$template -> assign_vars ( array (
2006-08-05 15:49:28 +00:00
'PROGRESS_BAR' => $user -> img ( 'upload_bar' , $user -> lang [ 'UPLOAD_IN_PROGRESS' ]))
2006-05-12 20:52:58 +00:00
);
2003-09-07 15:49:03 +00:00
2006-05-12 20:52:58 +00:00
$template -> display ( 'popup' );
2008-06-13 19:39:01 +00:00
garbage_collection ();
exit_handler ();
2003-09-07 15:49:03 +00:00
}
2005-04-09 12:26:45 +00:00
/**
2006-05-12 20:52:58 +00:00
* Do the various checks required for removing posts as well as removing it
2005-04-09 12:26:45 +00:00
*/
2006-05-12 20:52:58 +00:00
function handle_post_delete ( $forum_id , $topic_id , $post_id , & $post_data )
2003-09-07 15:23:55 +00:00
{
2008-09-23 18:04:52 +00:00
global $user , $db , $auth , $config ;
2006-06-06 20:53:46 +00:00
global $phpbb_root_path , $phpEx ;
2006-05-12 20:52:58 +00:00
// If moderator removing post or user itself removing post, present a confirmation screen
2008-09-23 18:04:52 +00:00
if ( $auth -> acl_get ( 'm_delete' , $forum_id ) || ( $post_data [ 'poster_id' ] == $user -> data [ 'user_id' ] && $user -> data [ 'is_registered' ] && $auth -> acl_get ( 'f_delete' , $forum_id ) && $post_id == $post_data [ 'topic_last_post_id' ] && ! $post_data [ 'post_edit_locked' ] && ( $post_data [ 'post_time' ] > time () - ( $config [ 'edit_time' ] * 60 ) || ! $config [ 'edit_time' ])))
2003-09-07 15:23:55 +00:00
{
2006-05-12 20:52:58 +00:00
$s_hidden_fields = build_hidden_fields ( array (
'p' => $post_id ,
'f' => $forum_id ,
'mode' => 'delete' )
2003-09-07 15:23:55 +00:00
);
2006-05-12 20:52:58 +00:00
if ( confirm_box ( true ))
2003-09-07 15:23:55 +00:00
{
2006-05-12 20:52:58 +00:00
$data = array (
'topic_first_post_id' => $post_data [ 'topic_first_post_id' ],
'topic_last_post_id' => $post_data [ 'topic_last_post_id' ],
2008-02-01 13:12:05 +00:00
'topic_replies_real' => $post_data [ 'topic_replies_real' ],
2006-05-12 20:52:58 +00:00
'topic_approved' => $post_data [ 'topic_approved' ],
'topic_type' => $post_data [ 'topic_type' ],
'post_approved' => $post_data [ 'post_approved' ],
2006-06-14 18:59:12 +00:00
'post_reported' => $post_data [ 'post_reported' ],
2006-05-12 20:52:58 +00:00
'post_time' => $post_data [ 'post_time' ],
2006-08-01 15:29:47 +00:00
'poster_id' => $post_data [ 'poster_id' ],
'post_postcount' => $post_data [ 'post_postcount' ]
2003-09-07 15:23:55 +00:00
);
2006-05-12 20:52:58 +00:00
$next_post_id = delete_post ( $forum_id , $topic_id , $post_id , $data );
2003-09-07 15:23:55 +00:00
2008-02-01 13:12:05 +00:00
if ( $next_post_id === false )
2003-09-07 15:23:55 +00:00
{
2006-05-12 20:52:58 +00:00
add_log ( 'mod' , $forum_id , $topic_id , 'LOG_DELETE_TOPIC' , $post_data [ 'topic_title' ]);
2004-09-01 15:47:46 +00:00
2006-06-06 20:53:46 +00:00
$meta_info = append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , " f= $forum_id " );
2006-05-12 20:52:58 +00:00
$message = $user -> lang [ 'POST_DELETED' ];
2003-09-07 15:23:55 +00:00
}
else
{
2006-05-12 20:52:58 +00:00
add_log ( 'mod' , $forum_id , $topic_id , 'LOG_DELETE_POST' , $post_data [ 'post_subject' ]);
2003-11-16 21:53:56 +00:00
2006-06-06 20:53:46 +00:00
$meta_info = append_sid ( " { $phpbb_root_path } viewtopic. $phpEx " , " f= $forum_id &t= $topic_id &p= $next_post_id " ) . " #p $next_post_id " ;
2006-05-12 20:52:58 +00:00
$message = $user -> lang [ 'POST_DELETED' ] . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_TOPIC' ], '<a href="' . $meta_info . '">' , '</a>' );
2003-09-07 15:23:55 +00:00
}
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
meta_refresh ( 3 , $meta_info );
2006-06-06 20:53:46 +00:00
$message .= '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_FORUM' ], '<a href="' . append_sid ( " { $phpbb_root_path } viewforum. $phpEx " , 'f=' . $forum_id ) . '">' , '</a>' );
2006-05-12 20:52:58 +00:00
trigger_error ( $message );
2003-09-07 15:23:55 +00:00
}
2006-05-12 20:52:58 +00:00
else
2006-01-11 18:56:07 +00:00
{
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
confirm_box ( false , 'DELETE_POST' , $s_hidden_fields );
2006-01-11 18:56:07 +00:00
}
2003-09-07 15:23:55 +00:00
}
2004-09-01 15:47:46 +00:00
2006-05-12 20:52:58 +00:00
// If we are here the user is not able to delete - present the correct error message
2007-04-10 20:50:14 +00:00
if ( $post_data [ 'poster_id' ] != $user -> data [ 'user_id' ] && $auth -> acl_get ( 'f_delete' , $forum_id ))
2005-10-19 18:00:10 +00:00
{
2006-05-12 20:52:58 +00:00
trigger_error ( 'DELETE_OWN_POSTS' );
2005-10-19 18:00:10 +00:00
}
2006-05-12 20:52:58 +00:00
if ( $post_data [ 'poster_id' ] == $user -> data [ 'user_id' ] && $auth -> acl_get ( 'f_delete' , $forum_id ) && $post_id != $post_data [ 'topic_last_post_id' ])
2004-08-04 18:29:29 +00:00
{
2006-05-12 20:52:58 +00:00
trigger_error ( 'CANNOT_DELETE_REPLIED' );
2004-08-04 18:29:29 +00:00
}
2004-07-08 22:41:04 +00:00
2006-05-12 20:52:58 +00:00
trigger_error ( 'USER_CANNOT_DELETE' );
2003-09-15 21:05:30 +00:00
}
2003-01-08 17:00:37 +00:00
?>