2002-07-14 14:37:47 +00:00
< ? php
/***************************************************************************
2002-10-03 02:43:41 +00:00
* functions_posting . php
2002-07-14 14:37:47 +00:00
* -------------------
* begin : Saturday , Feb 13 , 2001
* copyright : ( C ) 2001 The phpBB Group
* email : support @ phpbb . com
*
* $Id $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
***************************************************************************/
2002-10-04 13:09:10 +00:00
// Fill smiley templates (or just the variables) with smileys
// Either in a window or inline
function generate_smilies ( $mode )
2002-07-14 14:37:47 +00:00
{
2002-10-30 18:59:09 +00:00
global $SID , $auth , $db , $user , $config , $template ;
global $starttime , $phpEx , $phpbb_root_path ;
2002-07-14 14:37:47 +00:00
2003-03-22 15:48:46 +00:00
$max_smilies_inline = 20 ;
2003-02-27 23:37:02 +00:00
2002-11-07 22:02:04 +00:00
if ( $mode == 'window' )
2002-07-14 14:37:47 +00:00
{
2003-02-26 13:17:45 +00:00
$page_title = $user -> lang [ 'TOPIC_REVIEW' ] . " - $topic_title " ;
2002-10-04 13:09:10 +00:00
include ( $phpbb_root_path . 'includes/page_header.' . $phpEx );
2002-07-14 14:37:47 +00:00
2002-10-04 13:09:10 +00:00
$template -> set_filenames ( array (
2002-10-30 18:59:09 +00:00
'body' => 'posting_smilies.html' )
2002-10-04 13:09:10 +00:00
);
}
2002-07-14 14:37:47 +00:00
2002-11-07 22:02:04 +00:00
$where_sql = ( $mode == 'inline' ) ? 'WHERE display_on_posting = 1 ' : '' ;
2002-10-04 13:09:10 +00:00
$sql = " SELECT emoticon, code, smile_url, smile_width, smile_height
2003-03-20 01:25:59 +00:00
FROM " . SMILIES_TABLE . "
$where_sql
ORDER BY smile_order " ;
2003-02-27 23:37:02 +00:00
2002-10-04 13:09:10 +00:00
$result = $db -> sql_query ( $sql );
2002-07-14 14:37:47 +00:00
2002-10-04 13:09:10 +00:00
$num_smilies = 0 ;
$smile_array = array ();
2002-10-30 18:59:09 +00:00
if ( $row = $db -> sql_fetchrow ( $result ))
2002-10-04 13:09:10 +00:00
{
do
{
2002-10-30 18:59:09 +00:00
if ( ! in_array ( $row [ 'smile_url' ], $smile_array ))
2002-07-14 14:37:47 +00:00
{
2003-03-22 15:48:46 +00:00
if ( $mode == 'window' || ( $mode == 'inline' && $num_smilies < $max_smilies_inline ))
2002-07-14 14:37:47 +00:00
{
2002-10-04 13:09:10 +00:00
$template -> assign_block_vars ( 'emoticon' , array (
2002-10-30 18:59:09 +00:00
'SMILEY_CODE' => $row [ 'code' ],
'SMILEY_IMG' => $config [ 'smilies_path' ] . '/' . $row [ 'smile_url' ],
'SMILEY_WIDTH' => $row [ 'smile_width' ],
2002-10-04 13:09:10 +00:00
'SMILEY_HEIGHT' => $row [ 'smile_height' ],
2002-10-30 18:59:09 +00:00
'SMILEY_DESC' => $row [ 'emoticon' ])
2002-10-04 13:09:10 +00:00
);
2002-07-14 14:37:47 +00:00
}
2002-10-04 13:09:10 +00:00
$smile_array [] = $row [ 'smile_url' ];
$num_smilies ++ ;
2002-07-14 14:37:47 +00:00
}
}
2002-10-30 18:59:09 +00:00
while ( $row = $db -> sql_fetchrow ( $result ));
2002-10-04 13:09:10 +00:00
$db -> sql_freeresult ( $result );
2003-03-22 15:48:46 +00:00
if ( $mode == 'inline' && $num_smilies >= $max_smilies_inline )
2002-07-14 14:37:47 +00:00
{
2002-10-04 13:09:10 +00:00
$template -> assign_vars ( array (
2002-10-30 18:59:09 +00:00
'S_SHOW_EMOTICON_LINK' => true ,
'U_MORE_SMILIES' => " posting. $phpEx $SID &mode=smilies " )
2002-10-04 13:09:10 +00:00
);
2002-07-14 14:37:47 +00:00
}
}
2002-10-30 18:59:09 +00:00
if ( $mode == 'window' )
2002-07-14 14:37:47 +00:00
{
2002-10-04 13:09:10 +00:00
include ( $phpbb_root_path . 'includes/page_tail.' . $phpEx );
2002-07-14 14:37:47 +00:00
}
}
2003-02-27 23:37:02 +00:00
// DECODE TEXT -> This will/should be handled by bbcode.php eventually
2003-04-11 00:19:29 +00:00
function decode_text ( & $message , $bbcode_uid )
2003-02-27 23:37:02 +00:00
{
2003-04-21 14:13:10 +00:00
global $config ;
2003-02-27 23:37:02 +00:00
$server_protocol = ( $config [ 'cookie_secure' ]) ? 'https://' : 'http://' ;
$server_port = ( $config [ 'server_port' ] <> 80 ) ? ':' . trim ( $config [ 'server_port' ]) . '/' : '/' ;
2003-04-23 18:41:28 +00:00
$search = array (
'<br />' ,
" :u: $bbcode_uid " ,
" :o: $bbcode_uid " ,
" : $bbcode_uid "
);
$replace = array (
" \n " ,
'' ,
'' ,
''
);
$message = str_replace ( $search , $replace , $message );
2003-02-27 23:37:02 +00:00
$match = array (
'#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#' ,
'#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#' ,
'#<!\-\- w \-\-><a href="http:\/\/(.*?)" target="_blank">.*?</a><!\-\- w \-\->#' ,
'#<!\-\- l \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- l \-\->#' ,
'#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#' ,
2003-04-20 20:30:01 +00:00
'#<.*?>#s'
2003-02-27 23:37:02 +00:00
);
$replace = array (
'\1' ,
'\1' ,
'\1' ,
2003-04-21 14:13:10 +00:00
$server_protocol . trim ( $config [ 'server_name' ]) . $server_port . preg_replace ( '#^\/?(.*?)(\/)?$#' , '\1' , trim ( $config [ 'script_path' ])) . '/\1' ,
2003-02-27 23:37:02 +00:00
'\1' ,
2003-04-20 20:30:01 +00:00
''
2003-02-27 23:37:02 +00:00
);
$message = preg_replace ( $match , $replace , $message );
return ;
}
2003-03-28 01:25:03 +00:00
2003-03-22 15:48:46 +00:00
// Format text to be displayed - from viewtopic.php - centralizing this would be nice ;)
2003-03-12 14:21:57 +00:00
function format_display ( $message , $html , $bbcode , $uid , $url , $smilies , $sig )
{
2003-04-18 13:07:19 +00:00
global $auth , $forum_id , $config , $censors , $user , $bbcode , $phpbb_root_path ;
2003-03-12 14:21:57 +00:00
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
if ( $html && $auth -> acl_get ( 'f_bbcode' , $forum_id ))
{
$message = preg_replace ( '#(<)([\/]?.*?)(>)#is' , " < \\ 2> " , $message );
}
// Second parse bbcode here
2003-04-16 22:32:20 +00:00
$message = $bbcode -> bbcode_second_pass ( $message , $uid );
2003-03-12 14:21:57 +00:00
// If we allow users to disable display of emoticons
// we'll need an appropriate check and preg_replace here
2003-05-01 18:24:18 +00:00
$message = ( empty ( $smilies ) || empty ( $config [ 'allow_smilies' ])) ? preg_replace ( '#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#' , '\1' , $message ) : str_replace ( '<img src="{SMILE_PATH}' , '<img src="' . $phpbb_root_path . $config [ 'smilies_path' ], $message );
2003-03-12 14:21:57 +00:00
// Replace naughty words such as farty pants
if ( sizeof ( $censors ))
{
$message = str_replace ( '\"' , '"' , substr ( preg_replace ( '#(\>(((?>([^><]+|(?R)))*)\<))#se' , " preg_replace( \$ censors['match'], \$ censors['replace'], ' \\ 0') " , '>' . $message . '<' ), 1 , - 1 ));
}
$message = nl2br ( $message );
// Signature
$user_sig = ( $sig && $config [ 'allow_sig' ]) ? trim ( $user -> data [ 'user_sig' ]) : '' ;
2003-04-10 21:35:31 +00:00
if ( $user_sig != '' && $auth -> acl_get ( 'f_sigs' , $forum_id ))
2003-03-12 14:21:57 +00:00
{
if ( ! $auth -> acl_get ( 'f_html' , $forum_id ) && $user -> data [ 'user_allowhtml' ])
{
$user_sig = preg_replace ( '#(<)([\/]?.*?)(>)#is' , " < \\ 2> " , $user_sig );
}
$user_sig = ( empty ( $user -> data [ 'user_allowsmile' ]) || empty ( $config [ 'enable_smilies' ])) ? preg_replace ( '#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#' , '\1' , $user_sig ) : str_replace ( '<img src="{SMILE_PATH}' , '<img src="' . $config [ 'smilies_path' ], $user_sig );
if ( sizeof ( $censors ))
{
$user_sig = str_replace ( '\"' , '"' , substr ( preg_replace ( '#(\>(((?>([^><]+|(?R)))*)\<))#se' , " preg_replace( \$ censors['match'], \$ censors['replace'], ' \\ 0') " , '>' . $user_sig . '<' ), 1 , - 1 ));
}
$user_sig = '<br />_________________<br />' . nl2br ( $user_sig );
}
else
{
$user_sig = '' ;
}
2003-04-18 13:07:19 +00:00
$message = ( empty ( $smilies ) || empty ( $config [ 'allow_smilies' ])) ? preg_replace ( '#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#' , '\1' , $message ) : str_replace ( '<img src="{SMILE_PATH}' , '<img src="' . $phpbb_root_path . $config [ 'smilies_path' ], $message );
2003-03-12 14:21:57 +00:00
$message .= $user_sig ;
2003-04-20 16:49:26 +00:00
return $message ;
2003-03-12 14:21:57 +00:00
}
2003-04-19 10:28:37 +00:00
// Update Last Post Informations
function update_last_post_information ( $type , $id )
{
global $db ;
switch ( $type )
{
case 'forum' :
$sql_select_add = ', f.forum_parents' ;
$sql_table_add = ', ' . FORUMS_TABLE . ' f' ;
2003-05-05 22:48:17 +00:00
$sql_where_add = 'AND t.forum_id = f.forum_id AND f.forum_id = ' . $id ;
2003-04-19 10:28:37 +00:00
$sql_update_table = FORUMS_TABLE ;
break ;
case 'topic' :
$sql_select_add = '' ;
$sql_table_add = '' ;
2003-05-05 22:48:17 +00:00
$sql_where_add = 'AND t.topic_id = ' . $id ;
2003-04-19 10:28:37 +00:00
$sql_update_table = TOPICS_TABLE ;
break ;
default :
return ;
}
$sql = " SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username " . $sql_select_add . "
FROM " . POSTS_TABLE . " p , " . USERS_TABLE . " u , " . TOPICS_TABLE . " t " . $sql_table_add . "
WHERE p . post_approved = 1
AND t . topic_approved = 1
AND p . poster_id = u . user_id
AND t . topic_id = p . topic_id
$sql_where_add
ORDER BY p . post_time DESC " ;
$result = $db -> sql_query_limit ( $sql , 1 );
$row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
$update_sql = array (
2003-05-05 22:48:17 +00:00
$type . '_last_post_id' => ( int ) $row [ 'post_id' ],
$type . '_last_post_time' => ( int ) $row [ 'post_time' ],
$type . '_last_poster_id' => ( int ) $row [ 'poster_id' ],
$type . '_last_poster_name' => ( string ) ( $row [ 'poster_id' ] == ANONYMOUS ) ? trim ( $row [ 'post_username' ]) : trim ( $row [ 'username' ])
2003-04-19 10:28:37 +00:00
);
2003-05-05 22:48:17 +00:00
$sql = 'UPDATE ' . $sql_update_table . '
SET ' . $db->sql_build_array(' UPDATE ', $update_sql) . '
WHERE ' . (($type == ' forum ' ) ? " forum_id = $id " : " topic_id = $id " );
2003-04-19 10:28:37 +00:00
$db -> sql_query ( $sql );
}
2003-04-19 12:58:37 +00:00
// Delete Attachment
function delete_attachment ( $post_id_array = - 1 , $attach_id_array = - 1 , $page = - 1 , $user_id = - 1 )
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
global $db ;
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
// Generate Array, if it's not an array
if ( ( $post_id_array == - 1 ) && ( $attach_id_array == - 1 ) && ( $page == - 1 ) )
{
return ;
}
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
if ( ( $post_id_array == - 1 ) && ( $attach_id_array != - 1 ) )
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
$post_id_array = array ();
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
if ( ! is_array ( $attach_id_array ))
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
if ( strstr ( $attach_id_array , ', ' ))
{
$attach_id_array = explode ( ', ' , $attach_id_array );
}
else if ( strstr ( $attach_id_array , ',' ))
{
$attach_id_array = explode ( ',' , $attach_id_array );
}
else
{
$attach_id = intval ( $attach_id_array );
$attach_id_array = array ();
$attach_id_array [] = $attach_id ;
}
2003-03-12 14:21:57 +00:00
}
2003-04-19 12:58:37 +00:00
// Get the post_ids to fill the array
$p_id = ( $page == 'privmsgs' ) ? 'privmsgs_id' : 'post_id' ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$sql = " SELECT " . $p_id . "
FROM " . ATTACHMENTS_TABLE . "
WHERE attach_id IN ( " . implode(', ', $attach_id_array ) . " )
GROUP BY " . $p_id ;
$result = $db -> sql_query ( $sql );
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
while ( $row = $db -> sql_fetchrow ( $result ))
{
$post_id_array [] = intval ( $row [ $p_id ]);
}
$db -> sql_freeresult ( $result );
if ( count ( $post_id_array ) == 0 )
{
return ;
}
2003-03-12 14:21:57 +00:00
}
2003-04-19 12:58:37 +00:00
if ( ! is_array ( $post_id_array ))
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
if ( trim ( $post_id_array ) == '' )
{
return ;
}
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
if ( strstr ( $post_id_array , ', ' ))
{
$post_id_array = explode ( ', ' , $post_id_array );
}
else if ( strstr ( $post_id_array , ',' ))
{
$post_id_array = explode ( ',' , $post_id_array );
}
else
{
$post_id = intval ( $post_id_array );
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
$post_id_array = array ();
$post_id_array [] = $post_id ;
}
}
if ( count ( $post_id_array ) == 0 )
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
return ;
}
// First of all, determine the post id and attach_id
if ( $attach_id_array == - 1 )
{
$attach_id_array = array ();
// Get the attach_ids to fill the array
$whereclause = ( $page == 'privmsgs' ) ? 'WHERE privmsgs_id IN (' . implode ( ', ' , $post_id_array ) . ')' : 'WHERE post_id IN (' . implode ( ', ' , $post_id_array ) . ')' ;
$sql = " SELECT attach_id
FROM " . ATTACHMENTS_TABLE . " " .
$whereclause . "
GROUP BY attach_id " ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
{
$attach_id_array [] = intval ( $row [ 'attach_id' ]);
}
$db -> sql_freeresult ( $result );
if ( count ( $attach_id_array ) == 0 )
{
return ;
}
}
2003-04-18 13:07:19 +00:00
2003-04-19 12:58:37 +00:00
if ( ! is_array ( $attach_id_array ))
{
if ( strstr ( $attach_id_array , ', ' ))
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
$attach_id_array = explode ( ', ' , $attach_id_array );
}
else if ( strstr ( $attach_id_array , ',' ))
{
$attach_id_array = explode ( ',' , $attach_id_array );
}
else
{
$attach_id = intval ( $attach_id_array );
2003-04-18 13:07:19 +00:00
2003-04-19 12:58:37 +00:00
$attach_id_array = array ();
$attach_id_array [] = $attach_id ;
2003-04-18 13:07:19 +00:00
}
2003-04-19 12:58:37 +00:00
}
2003-04-18 13:07:19 +00:00
2003-04-19 12:58:37 +00:00
if ( count ( $attach_id_array ) == 0 )
{
return ;
}
if ( $page == 'privmsgs' )
{
$sql_id = 'privmsgs_id' ;
if ( $user_id != - 1 )
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
$post_id_array_2 = array ();
$sql = " SELECT privmsgs_type, privmsgs_to_userid, privmsgs_from_userid
FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id IN ( " . implode(', ', $post_id_array ) . " ) " ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
switch ( intval ( $row [ 'privmsgs_type' ]))
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
case PRIVMSGS_READ_MAIL :
case PRIVMSGS_NEW_MAIL :
case PRIVMSGS_UNREAD_MAIL :
if ( $row [ 'privmsgs_to_userid' ] == $user_id )
{
$post_id_array_2 [] = $privmsgs_id ;
}
break ;
case PRIVMSGS_SENT_MAIL :
if ( $row [ 'privmsgs_from_userid' ] == $user_id )
{
$post_id_array_2 [] = $privmsgs_id ;
}
break ;
case PRIVMSGS_SAVED_OUT_MAIL :
if ( $row [ 'privmsgs_from_userid' ] == $user_id )
{
$post_id_array_2 [] = $privmsgs_id ;
}
break ;
case PRIVMSGS_SAVED_IN_MAIL :
if ( $row [ 'privmsgs_to_userid' ] == $user_id )
{
$post_id_array_2 [] = $privmsgs_id ;
}
break ;
2003-04-18 13:07:19 +00:00
}
}
2003-04-19 12:58:37 +00:00
$db -> sql_freeresult ( $result );
$post_id_array = $post_id_array_2 ;
2003-04-18 13:07:19 +00:00
}
2003-04-19 12:58:37 +00:00
}
else
{
$sql_id = 'post_id' ;
2003-03-12 14:21:57 +00:00
}
2003-04-19 12:58:37 +00:00
$sql = " DELETE FROM " . ATTACHMENTS_TABLE . "
WHERE attach_id IN ( " . implode(', ', $attach_id_array ) . " )
AND " . $sql_id . " IN ( " . implode(', ', $post_id_array ) . " ) " ;
$db -> sql_query ( $sql );
foreach ( $attach_id_array as $attach_id )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " SELECT attach_id
FROM " . ATTACHMENTS_TABLE . "
WHERE attach_id = " . $attach_id ;
$select_result = $db -> sql_query ( $sql );
if ( ! is_array ( $db -> sql_fetchrow ( $select_result )))
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " SELECT attach_id, physical_filename, thumbnail
FROM " . ATTACHMENTS_DESC_TABLE . "
WHERE attach_id = " . $attach_id ;
$result = $db -> sql_query ( $sql );
// delete attachments
while ( $row = $db -> sql_fetchrow ( $result ))
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
phpbb_unlink ( $row [ 'physical_filename' ], 'file' , $config [ 'use_ftp_upload' ]);
if ( intval ( $row [ 'thumbnail' ]) == 1 )
{
phpbb_unlink ( $row [ 'physical_filename' ], 'thumbnail' , $config [ 'use_ftp_upload' ]);
}
$sql = " DELETE FROM " . ATTACHMENTS_DESC_TABLE . "
WHERE attach_id = " . $row['attach_id'] ;
2003-04-18 13:07:19 +00:00
$db -> sql_query ( $sql );
}
2003-04-19 12:58:37 +00:00
$db -> sql_freeresult ( $result );
2003-04-18 13:07:19 +00:00
}
2003-04-19 12:58:37 +00:00
$db -> sql_freeresult ( $select_result );
}
// Now Sync the Topic/PM
if ( $page == 'privmsgs' )
{
foreach ( $post_id_array as $privmsgs_id )
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " SELECT attach_id
FROM " . ATTACHMENTS_TABLE . "
WHERE privmsgs_id = " . $privmsgs_id ;
$select_result = $db -> sql_query ( $sql );
2003-04-18 13:07:19 +00:00
2003-04-19 12:58:37 +00:00
if ( ! is_array ( $db -> sql_fetchrow ( $select_result )))
{
$sql = " UPDATE " . PRIVMSGS_TABLE . "
SET privmsgs_attachment = 0
WHERE privmsgs_id = " . $privmsgs_id ;
$db -> sql_query ( $sql );
}
$db -> sql_freeresult ( $select_result );
2003-04-18 13:07:19 +00:00
}
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
else
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " SELECT topic_id
FROM " . POSTS_TABLE . "
WHERE post_id IN ( " . implode(', ', $post_id_array ) . " )
GROUP BY topic_id " ;
$result = $db -> sql_query ( $sql );
while ( $row = $db -> sql_fetchrow ( $result ))
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
$topic_id = intval ( $row [ 'topic_id' ]);
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
$sql = " SELECT post_id
FROM " . POSTS_TABLE . "
WHERE topic_id = " . $topic_id . "
GROUP BY post_id " ;
$result2 = $db -> sql_query ( $sql );
$post_ids = array ();
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
while ( $post_row = $db -> sql_fetchrow ( $result2 ))
{
$post_ids [] = intval ( $post_row [ 'post_id' ]);
}
$db -> sql_freeresult ( $result2 );
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
if ( count ( $post_ids ))
{
$post_id_sql = implode ( ', ' , $post_ids );
$sql = " SELECT attach_id
FROM " . ATTACHMENTS_TABLE . "
WHERE post_id IN ( " . $post_id_sql . " ) " ;
$select_result = $db -> sql_query_limit ( $sql , 1 );
$set_id = ( ! is_array ( $db -> sql_fetchrow ( $select_result ))) ? 0 : 1 ;
$db -> sql_freeresult ( $select_result );
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
$sql = " UPDATE " . TOPICS_TABLE . "
SET topic_attachment = " . $set_id . "
WHERE topic_id = " . $topic_id ;
$db -> sql_query ( $sql );
foreach ( $post_ids as $post_id )
{
$sql = " SELECT attach_id
FROM " . ATTACHMENTS_TABLE . "
WHERE post_id = " . $post_id ;
$select_result = $db -> sql_query_limit ( $sql , 1 );
$set_id = ( ! is_array ( $db -> sql_fetchrow ( $select_result ))) ? 0 : 1 ;
$db -> sql_freeresult ( $select_result );
$sql = " UPDATE " . POSTS_TABLE . "
SET post_attachment = " . $set_id . "
WHERE post_id = " . $post_id ;
$db -> sql_query ( $sql );
}
}
2003-03-12 14:21:57 +00:00
}
2003-04-19 12:58:37 +00:00
$db -> sql_freeresult ( $result );
}
}
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
// Upload Attachment - filedata is generated here
function upload_attachment ( $filename )
{
global $_POST , $_FILES , $auth , $user , $config , $db ;
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
$filedata = array ();
$filedata [ 'error' ] = false ;
$filedata [ 'err_msg' ] = '' ;
$filedata [ 'post_attach' ] = ( $filename != '' ) ? true : false ;
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
if ( ! $filedata [ 'post_attach' ])
2003-03-12 14:21:57 +00:00
{
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-03-12 14:21:57 +00:00
}
2003-04-19 12:58:37 +00:00
$r_file = $filename ;
$file = $_FILES [ 'fileupload' ][ 'tmp_name' ];
$filedata [ 'mimetype' ] = $_FILES [ 'fileupload' ][ 'type' ];
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
// Opera add the name to the mime type
$filedata [ 'mimetype' ] = ( strstr ( $filedata [ 'mimetype' ], '; name' ) ) ? str_replace ( strstr ( $filedata [ 'mimetype' ], '; name' ), '' , $filedata [ 'mimetype' ]) : $filedata [ 'mimetype' ];
2003-05-01 18:24:18 +00:00
$filedata [ 'extension' ] = array_pop ( explode ( '.' , strtolower ( $filename )));
2003-04-19 12:58:37 +00:00
$filedata [ 'filesize' ] = ( !@ filesize ( $file )) ? intval ( $_FILES [ 'size' ]) : @ filesize ( $file );
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
$extensions = array ();
obtain_attach_extensions ( $extensions );
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
// Check Extension
if ( ! in_array ( $filedata [ 'extension' ], $extensions [ '_allowed_' ]))
2003-03-12 14:21:57 +00:00
{
2003-04-19 12:58:37 +00:00
$filedata [ 'error' ] = true ;
$filedata [ 'err_msg' ] = sprintf ( $user -> lang [ 'DISALLOWED_EXTENSION' ], $filedata [ 'extension' ]);
$filedata [ 'post_attach' ] = false ;
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-04-19 12:58:37 +00:00
}
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
$allowed_filesize = ( $extensions [ $filedata [ 'extension' ]][ 'max_filesize' ] != 0 ) ? $extensions [ $filedata [ 'extension' ]][ 'max_filesize' ] : $config [ 'max_filesize' ];
$cat_id = $extensions [ $filedata [ 'extension' ]][ 'display_cat' ];
2003-03-12 14:21:57 +00:00
2003-04-19 12:58:37 +00:00
// check Filename
if ( preg_match ( " /[ \\ /:*? \" <>|]/i " , $filename ) )
{
$filedata [ 'error' ] = true ;
$filedata [ 'err_msg' ] = sprintf ( $user -> lang [ 'INVALID_FILENAME' ], $filename );
$filedata [ 'post_attach' ] = false ;
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-04-19 12:58:37 +00:00
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
// check php upload-size
if ( ( $file == 'none' ) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$filedata [ 'error' ] = true ;
$filedata [ 'err_msg' ] = ( @ ini_get ( 'upload_max_filesize' ) == '' ) ? $user -> lang [ 'ATTACHMENT_PHP_SIZE_NA' ] : sprintf ( $user -> lang [ 'ATTACHMENT_PHP_SIZE_OVERRUN' ], @ ini_get ( 'upload_max_filesize' ));
$filedata [ 'post_attach' ] = false ;
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
/*
// Check Image Size, if it is an image
if ( ( ! $acl -> gets ( 'm_' , 'a_' )) && ( $cat_id == IMAGE_CAT ) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
list ( $width , $height ) = image_getdimension ( $file );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( ( $width != 0 ) && ( $height != 0 ) && ( intval ( $attach_config [ 'img_max_width' ]) != 0 ) && ( intval ( $attach_config [ 'img_max_height' ]) != 0 ) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( ( $width > intval ( $attach_config [ 'img_max_width' ])) || ( $height > intval ( $attach_config [ 'img_max_height' ])) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$error = TRUE ;
if ( ! empty ( $error_msg ))
{
$error_msg .= '<br />' ;
}
$error_msg .= sprintf ( $lang [ 'Error_imagesize' ], intval ( $attach_config [ 'img_max_width' ]), intval ( $attach_config [ 'img_max_height' ]));
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
}
*/
// check Filesize
if ( ( $allowed_filesize != 0 ) && ( $filedata [ 'filesize' ] > $allowed_filesize ) && ( ! $acl -> gets ( 'm_' , 'a_' )) )
{
$size_lang = ( $allowed_filesize >= 1048576 ) ? $user -> lang [ 'MB' ] : ( ( $allowed_filesize >= 1024 ) ? $user -> lang [ 'KB' ] : $user -> lang [ 'BYTES' ] );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( $allowed_filesize >= 1048576 )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$allowed_filesize = round ( $allowed_filesize / 1048576 * 100 ) / 100 ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
else if ( $allowed_filesize >= 1024 )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$allowed_filesize = round ( $allowed_filesize / 1024 * 100 ) / 100 ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
$filedata [ 'error' ] = true ;
$filedata [ 'err_msg' ] = sprintf ( $user -> lang [ 'ATTACHMENT_TOO_BIG' ], $allowed_filesize , $size_lang );
$filedata [ 'post_attach' ] = false ;
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Check our complete quota
if ( $config [ 'attachment_quota' ] != 0 )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( $config [ 'total_filesize' ] + $filedata [ 'filesize' ] > $config [ 'attachment_quota' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$filedata [ 'error' ] = true ;
$filedata [ 'err_msg' ] = $user -> lang [ 'ATTACH_QUOTA_REACHED' ];
$filedata [ 'post_attach' ] = false ;
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
/*
// If we are at Private Messaging, check our PM Quota
if ( $this -> page == PAGE_PRIVMSGS )
{
$to_user = ( isset ( $_POST [ 'username' ]) ) ? $_POST [ 'username' ] : '' ;
if ( intval ( $config [ 'pm_filesize_limit' ]) != 0 )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$total_filesize = get_total_attach_pm_filesize ( 'from_user' , $user -> data [ 'user_id' ]);
if ( ( $total_filesize + $filedata [ 'filesize' ] > intval ( $config [ 'pm_filesize_limit' ])) )
{
$error = TRUE ;
if ( ! empty ( $error_msg ))
{
$error_msg .= '<br />' ;
}
$error_msg .= $lang [ 'Attach_quota_sender_pm_reached' ];
}
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Check Receivers PM Quota
if (( ! empty ( $to_user )) && ( $userdata [ 'user_level' ] != ADMIN ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " SELECT user_id
FROM " . USERS_TABLE . "
WHERE username = '" . $to_user . "' " ;
$result = $db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$row = $db -> sql_fetchrow ( $result );
$db -> sql_freeresult ( $result );
$user_id = intval ( $row [ 'user_id' ]);
$u_data = get_userdata ( $user_id );
$this -> get_quota_limits ( $u_data , $user_id );
if ( intval ( $attach_config [ 'pm_filesize_limit' ]) != 0 )
{
$total_filesize = get_total_attach_pm_filesize ( 'to_user' , $user_id );
if ( $total_filesize + $this -> filesize > intval ( $attach_config [ 'pm_filesize_limit' ]))
{
$error = TRUE ;
if ( ! empty ( $error_msg ))
{
$error_msg .= '<br />' ;
}
$error_msg .= sprintf ( $lang [ 'Attach_quota_receiver_pm_reached' ], $to_user );
}
}
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
*/
$filedata [ 'thumbnail' ] = 0 ;
// Prepare Values
$filedata [ 'filetime' ] = time ();
$filedata [ 'filename' ] = stripslashes ( $r_file );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$filedata [ 'destination_filename' ] = strtolower ( $filedata [ 'filename' ]);
$filedata [ 'destination_filename' ] = $user -> data [ 'user_id' ] . '_' . $filedata [ 'filetime' ] . '.' . $filedata [ 'extension' ];
$filedata [ 'filename' ] = str_replace ( " ' " , " \ ' " , $filedata [ 'filename' ]);
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
/*
// Do we have to create a thumbnail ?
if ( ( $cat_id == IMAGE_CAT ) && ( $config [ 'img_create_thumbnail' ]) )
{
$this -> thumbnail = 1 ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
*/
// Upload Attachment
if ( ! $config [ 'use_ftp_upload' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
// Descide the Upload method
if ( @ ini_get ( 'open_basedir' ) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$upload_mode = 'move' ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
else if ( @ ini_get ( 'safe_mode' ) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$upload_mode = 'move' ;
2003-03-22 15:48:46 +00:00
}
else
{
2003-04-19 12:58:37 +00:00
$upload_mode = 'copy' ;
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
else
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$upload_mode = 'ftp' ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Ok, upload the File
$result = move_uploaded_attachment ( $upload_mode , $file , $filedata );
if ( $result != '' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$filedata [ 'error' ] = true ;
$filedata [ 'err_msg' ] = $result ;
$filedata [ 'post_attach' ] = false ;
}
2003-04-20 16:49:26 +00:00
return $filedata ;
2003-04-19 12:58:37 +00:00
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
// Move/Upload File - could be used for Avatars too ?
function move_uploaded_attachment ( $upload_mode , $source_filename , & $filedata )
{
global $user , $config ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$destination_filename = $filedata [ 'destination_filename' ];
$thumbnail = ( isset ( $filedata [ 'thumbnail' ])) ? $filedata [ 'thumbnail' ] : false ;
switch ( $upload_mode )
{
case 'copy' :
if ( !@ copy ( $source_filename , $config [ 'upload_dir' ] . '/' . $destination_filename ) )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( !@ move_uploaded_file ( $source_filename , $config [ 'upload_dir' ] . '/' . $destination_filename ) )
2003-03-22 15:48:46 +00:00
{
2003-04-20 16:49:26 +00:00
return sprintf ( $user -> lang [ 'GENERAL_UPLOAD_ERROR' ], './' . $config [ 'upload_dir' ] . '/' . $destination_filename );
2003-04-19 12:58:37 +00:00
}
}
@ chmod ( $config [ 'upload_dir' ] . '/' . $destination_filename , 0666 );
break ;
case 'move' :
if ( !@ move_uploaded_file ( $source_filename , $config [ 'upload_dir' ] . '/' . $destination_filename ) )
{
if ( !@ copy ( $source_file , $config [ 'upload_dir' ] . '/' . $destination_filename ) )
{
2003-04-20 16:49:26 +00:00
return sprintf ( $user -> lang [ 'GENERAL_UPLOAD_ERROR' ], './' . $config [ 'upload_dir' ] . '/' . $destination_filename );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
}
@ chmod ( $config [ 'upload_dir' ] . '/' . $destination_filename , 0666 );
break ;
case 'ftp' :
/*
$conn_id = init_ftp ();
// Binary or Ascii ?
$mode = FTP_BINARY ;
if ( ( preg_match ( " /text/i " , $filedata [ 'mimetype' ])) || ( preg_match ( " /html/i " , $filedata [ 'mimetype' ])) )
{
$mode = FTP_ASCII ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
$res = @ ftp_put ( $conn_id , $destination_filename , $source_filename , $mode );
if ( ! $res )
{
@ ftp_quit ( $conn_id );
2003-04-20 16:49:26 +00:00
return sprintf ( $user -> lang [ 'Ftp_error_upload' ], $config [ 'ftp_path' ]);
2003-04-19 12:58:37 +00:00
}
@ ftp_site ( $conn_id , 'CHMOD 0644 ' . $destination_filename );
@ ftp_quit ( $conn_id );
break ;
*/
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
$filedata [ 'thumbnail' ] = 0 ;
/* if ( $filedata [ 'thumbnail' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( $upload_mode == 'ftp' )
{
$source = $source_filename ;
$destination = 'thumbs/t_' . $destination_filename ;
}
else
{
$source = $config [ 'upload_dir' ] . '/' . $destination_filename ;
$destination = phpbb_realpath ( $config [ 'upload_dir' ]);
$destination .= '/thumbs/t_' . $destination_filename ;
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( ! create_thumbnail ( $source , $destination , $filedata [ 'mimetype' ]))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( ! create_thumbnail ( $source_filename , $destination_filename , $filedata [ 'mimetype' ]))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$filedata [ 'thumbnail' ] = 0 ;
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
} */
2003-04-20 16:49:26 +00:00
return '' ;
2003-04-19 12:58:37 +00:00
}
// Delete File
function phpbb_unlink ( $filename , $mode = 'file' , $use_ftp = false )
{
global $config , $user ;
if ( ! $use_ftp )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$filename = ( $mode == 'thumbnail' ) ? $config [ 'upload_dir' ] . '/thumbs/t_' . $filename : $config [ 'upload_dir' ] . '/' . $filename ;
$deleted = @ unlink ( $filename );
if ( @ file_exists ( $filename ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$filesys = eregi_replace ( '/' , '\\' , $filename );
$deleted = @ system ( " del $filesys " );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( @ file_exists ( $filename ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
@ chmod ( $filename , 0777 );
$deleted = @ unlink ( $filename );
if ( ! $deleted )
{
$deleted = @ system ( " del $filename " );
}
2003-03-22 15:48:46 +00:00
}
}
}
else
{
2003-04-19 12:58:37 +00:00
/* $conn_id = attach_init_ftp ( $mode );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( $mode == MODE_THUMBNAIL )
{
$filename = 't_' . $filename ;
}
$res = @ ftp_delete ( $conn_id , $filename );
if ( ! $res )
{
if ( defined ( 'DEBUG_EXTRA' ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$add = ( $mode == MODE_THUMBNAIL ) ? ( '/' . THUMB_DIR ) : '' ;
message_die ( GENERAL_ERROR , sprintf ( $lang [ 'Ftp_error_delete' ], $attach_config [ 'ftp_path' ] . $add ));
2003-03-22 15:48:46 +00:00
}
2003-04-20 16:49:26 +00:00
return $deleted ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
@ ftp_quit ( $conn_id );
$deleted = TRUE ; */
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
2003-04-20 16:49:26 +00:00
return $deleted ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
//
// posting.php specific
//
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
// Submit Post
2003-05-01 18:24:18 +00:00
function submit_post ( $mode , $message , $subject , $username , $topic_type , $bbcode_uid , $poll , $attachment_data , $filename_data , $post_data )
2003-04-19 12:58:37 +00:00
{
global $db , $auth , $user , $config , $phpEx , $SID , $template ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$search = new fulltext_search ();
$current_time = time ();
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$post_data [ 'subject' ] = $subject ;
$db -> sql_transaction ();
// Initial Topic table info
if ( ( $mode == 'post' ) || ( $mode == 'edit' && $post_data [ 'topic_first_post_id' ] == $post_data [ 'post_id' ]))
2003-04-15 18:56:31 +00:00
{
2003-04-19 12:58:37 +00:00
$topic_sql = array (
'forum_id' => $post_data [ 'forum_id' ],
'topic_title' => stripslashes ( $subject ),
'topic_time' => $current_time ,
'topic_type' => $topic_type ,
'topic_approved' => ( $auth -> acl_get ( 'f_moderate' , $post_data [ 'forum_id' ]) && ! $auth -> acl_get ( 'f_ignorequeue' , $post_data [ 'forum_id' ])) ? 0 : 1 ,
'icon_id' => $post_data [ 'icon_id' ],
2003-05-01 18:24:18 +00:00
'topic_attachment' => ( sizeof ( $filename_data [ 'physical_filename' ])) ? 1 : 0 ,
2003-04-19 12:58:37 +00:00
'topic_poster' => intval ( $user -> data [ 'user_id' ]),
'topic_first_poster_name' => ( $username != '' ) ? stripslashes ( $username ) : (( $user -> data [ 'user_id' ] == ANONYMOUS ) ? '' : stripslashes ( $user -> data [ 'username' ]))
);
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( ! empty ( $poll [ 'poll_options' ]))
{
$topic_sql = array_merge ( $topic_sql , array (
'poll_title' => stripslashes ( $poll [ 'poll_title' ]),
2003-04-22 16:47:34 +00:00
'poll_start' => ( $poll [ 'poll_start' ]) ? $poll [ 'poll_start' ] : $current_time ,
'poll_max_options' => $poll [ 'poll_max_options' ],
2003-04-19 12:58:37 +00:00
'poll_length' => $poll [ 'poll_length' ] * 3600 )
);
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$sql = ( $mode == 'post' ) ? 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db -> sql_build_array ( 'INSERT' , $topic_sql ) : 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db -> sql_build_array ( 'UPDATE' , $topic_sql ) . ' WHERE topic_id = ' . $post_data [ 'topic_id' ];
$db -> sql_query ( $sql );
$post_data [ 'topic_id' ] = ( $mode == 'post' ) ? $db -> sql_nextid () : $post_data [ 'topic_id' ];
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Post table info
$post_sql = array (
'topic_id' => $post_data [ 'topic_id' ],
'forum_id' => $post_data [ 'forum_id' ],
'poster_id' => ( $mode == 'edit' ) ? $post_data [ 'poster_id' ] : intval ( $user -> data [ 'user_id' ]),
'post_username' => ( $username != '' ) ? stripslashes ( $username ) : '' ,
'post_subject' => stripslashes ( $subject ),
'icon_id' => $post_data [ 'icon_id' ],
'poster_ip' => $user -> ip ,
'post_approved' => ( $auth -> acl_get ( 'f_moderate' , $post_data [ 'forum_id' ]) && ! $auth -> acl_get ( 'f_ignorequeue' , $post_data [ 'forum_id' ])) ? 0 : 1 ,
'post_edit_time' => ( $mode == 'edit' && $post_data [ 'poster_id' ] == $user -> data [ 'user_id' ]) ? $current_time : 0 ,
'enable_sig' => $post_data [ 'enable_sig' ],
'enable_bbcode' => $post_data [ 'enable_bbcode' ],
'enable_html' => $post_data [ 'enable_html' ],
'enable_smilies' => $post_data [ 'enable_smilies' ],
'enable_magic_url' => $post_data [ 'enable_urls' ],
'bbcode_uid' => $bbcode_uid ,
'bbcode_bitfield' => $post_data [ 'bbcode_bitfield' ],
'post_edit_locked' => $post_data [ 'post_edit_locked' ]
);
2003-05-06 00:42:04 +00:00
if ( $mode != 'edit' )
{
$post_sql [ 'post_time' ] = $current_time ;
}
2003-04-19 12:58:37 +00:00
if ( $mode != 'edit' || $post_data [ 'message_md5' ] != $post_data [ 'post_checksum' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$post_sql = array_merge ( $post_sql , array (
'post_checksum' => $post_data [ 'message_md5' ],
'post_text' => $message ,
'post_encoding' => $user -> lang [ 'ENCODING' ]
));
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
$sql = ( $mode == 'edit' ) ? 'UPDATE ' . POSTS_TABLE . ' SET ' . $db -> sql_build_array ( 'UPDATE' , $post_sql ) . ' , post_edit_count = post_edit_count + 1 WHERE post_id = ' . $post_data [ 'post_id' ] : 'INSERT INTO ' . POSTS_TABLE . ' ' . $db -> sql_build_array ( 'INSERT' , $post_sql );
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$post_data [ 'post_id' ] = ( $mode == 'edit' ) ? $post_data [ 'post_id' ] : $db -> sql_nextid ();
// Submit Poll
if ( ! empty ( $poll [ 'poll_options' ]))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$cur_poll_options = array ();
if ( $poll [ 'poll_start' ] && $mode == 'edit' )
{
$sql = " SELECT * FROM " . POLL_OPTIONS_TABLE . "
WHERE topic_id = " . $post_data['topic_id'] . "
ORDER BY poll_option_id " ;
$result = $db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
while ( $cur_poll_options [] = $db -> sql_fetchrow ( $result ));
$db -> sql_freeresult ( $result );
}
for ( $i = 0 ; $i < sizeof ( $poll [ 'poll_options' ]); $i ++ )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( trim ( $poll [ 'poll_options' ][ $i ]) != '' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( empty ( $cur_poll_options [ $i ]))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " INSERT INTO " . POLL_OPTIONS_TABLE . " (poll_option_id, topic_id, poll_option_text)
VALUES ( " . $i . " , " . $post_data['topic_id'] . " , '" . $db->sql_escape($poll[' poll_options '][$i]) . "' ) " ;
$db -> sql_query ( $sql );
}
else if ( $poll [ 'poll_options' ][ $i ] != $cur_poll_options [ $i ])
{
$sql = " UPDATE " . POLL_OPTIONS_TABLE . "
SET poll_option_text = '" . $db->sql_escape($poll[' poll_options '][$i]) . "'
WHERE poll_option_id = " . $cur_poll_options[$i] ['poll_option_id'];
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
}
}
2003-04-19 12:58:37 +00:00
if ( sizeof ( $poll [ 'poll_options' ]) < sizeof ( $cur_poll_options ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " DELETE FROM " . POLL_OPTIONS_TABLE . "
WHERE poll_option_id > " . sizeof( $poll['poll_options'] ) . "
AND topic_id = " . $post_data['topic_id'] ;
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
// Submit Attachments
2003-05-01 18:24:18 +00:00
if ( count ( $attachment_data ) && ! empty ( $post_data [ 'post_id' ]) && ( $mode == 'post' || $mode == 'reply' || $mode == 'edit' ))
2003-03-22 15:48:46 +00:00
{
2003-05-01 18:24:18 +00:00
foreach ( $attachment_data as $attach_row )
2003-03-22 15:48:46 +00:00
{
2003-05-01 18:24:18 +00:00
if ( $attach_row [ 'attach_id' ] != '-1' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
// update entry in db if attachment already stored in db and filespace
$attach_sql = array (
2003-05-01 18:24:18 +00:00
'comment' => trim ( $attach_row [ 'comment' ])
2003-04-19 12:58:37 +00:00
);
2003-05-01 18:24:18 +00:00
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . ' SET ' . $db -> sql_build_array ( 'UPDATE' , $attach_sql ) . ' WHERE attach_id = ' . intval ( $attach_row [ 'attach_id' ]);
2003-04-19 12:58:37 +00:00
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
else
{
// insert attachment into db
$attach_sql = array (
2003-05-01 18:24:18 +00:00
'physical_filename' => $attach_row [ 'physical_filename' ],
'real_filename' => $attach_row [ 'real_filename' ],
'comment' => trim ( $attach_row [ 'comment' ]),
'extension' => $attach_row [ 'extension' ],
'mimetype' => $attach_row [ 'mimetype' ],
'filesize' => $attach_row [ 'filesize' ],
'filetime' => $attach_row [ 'filetime' ],
'thumbnail' => $attach_row [ 'thumbnail' ]
2003-04-19 12:58:37 +00:00
);
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' . $db -> sql_build_array ( 'INSERT' , $attach_sql );
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$attach_sql = array (
'attach_id' => $db -> sql_nextid (),
'post_id' => $post_data [ 'post_id' ],
'privmsgs_id' => 0 ,
'user_id_from' => ( $mode == 'edit' ) ? $post_data [ 'poster_id' ] : intval ( $user -> data [ 'user_id' ]),
'user_id_to' => 0
);
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db -> sql_build_array ( 'INSERT' , $attach_sql );
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
2003-05-01 18:24:18 +00:00
if ( count ( $attachment_data ))
2003-04-19 12:58:37 +00:00
{
$sql = " UPDATE " . POSTS_TABLE . "
SET post_attachment = 1
WHERE post_id = " . $post_data['post_id'] ;
$db -> sql_query ( $sql );
$sql = " UPDATE " . TOPICS_TABLE . "
SET topic_attachment = 1
WHERE topic_id = " . $post_data['topic_id'] ;
$db -> sql_query ( $sql );
}
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Fulltext parse
2003-05-05 22:48:17 +00:00
if ( $post_data [ 'message_md5' ] != $post_data [ 'post_checksum' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$result = $search -> add ( $mode , $post_data [ 'post_id' ], $message , $subject );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Sync forums, topics and users ...
if ( $mode != 'edit' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$forum_topics_sql = ( $mode == 'post' ) ? ', forum_topics = forum_topics + 1, forum_topics_real = forum_topics_real + 1' : '' ;
$forum_sql = array (
'forum_last_post_id' => $post_data [ 'post_id' ],
'forum_last_post_time' => $current_time ,
'forum_last_poster_id' => intval ( $user -> data [ 'user_id' ]),
'forum_last_poster_name' => ( $user -> data [ 'user_id' ] == ANONYMOUS ) ? stripslashes ( $username ) : $user -> data [ 'username' ],
);
2003-05-05 22:48:17 +00:00
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_build_array(' UPDATE ', $forum_sql) . ' , forum_posts = forum_posts + 1 ' . $forum_topics_sql . '
WHERE forum_id = ' . $post_data[' forum_id ' ];
2003-04-19 12:58:37 +00:00
$db -> sql_query ( $sql );
// Update topic: first/last post info, replies
$topic_sql = array (
'topic_last_post_id' => $post_data [ 'post_id' ],
'topic_last_post_time' => $current_time ,
'topic_last_poster_id' => intval ( $user -> data [ 'user_id' ]),
'topic_last_poster_name' => ( $username != '' ) ? stripslashes ( $username ) : (( $user -> data [ 'user_id' ] == ANONYMOUS ) ? '' : stripslashes ( $user -> data [ 'username' ])),
);
if ( $mode == 'post' )
{
$topic_sql = array_merge ( $topic_sql , array (
'topic_first_post_id' => $post_data [ 'post_id' ],
));
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
2003-04-23 18:41:28 +00:00
$topic_replies_sql = ( $mode == 'reply' || $mode == 'quote' ) ? ', topic_replies = topic_replies + 1, topic_replies_real = topic_replies_real + 1' : '' ;
2003-05-05 22:48:17 +00:00
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_build_array(' UPDATE ', $topic_sql) . $topic_replies_sql . '
WHERE topic_id = ' . $post_data[' topic_id ' ];
2003-04-19 12:58:37 +00:00
$db -> sql_query ( $sql );
// Update user post count ... if appropriate
if ( $user -> data [ 'user_id' ] != ANONYMOUS && $auth -> acl_get ( 'f_postcount' , $post_data [ 'forum_id' ]))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + 1
WHERE user_id = ' . intval($user->data[' user_id ' ]);
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// post counts for index, etc.
if ( $mode == 'post' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
set_config ( 'num_topics' , $config [ 'num_topics' ] + 1 , TRUE );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
set_config ( 'num_posts' , $config [ 'num_posts' ] + 1 , TRUE );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Topic Notification
2003-05-05 22:48:17 +00:00
if ( ! $post_data [ 'notify_set' ] && $post_data [ 'notify' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$sql = " INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id)
VALUES ( " . $user->data ['user_id'] . " , " . $post_data['topic_id'] . " ) " ;
$db -> sql_query ( $sql );
}
2003-05-05 22:48:17 +00:00
else if ( $post_data [ 'notify_set' ] && ! $post_data [ 'notify' ])
2003-04-19 12:58:37 +00:00
{
$sql = " DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE user_id = " . $user->data ['user_id'] . "
AND topic_id = " . $post_data['topic_id'] ;
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// Mark this topic as read and posted to.
2003-04-22 16:47:34 +00:00
$mark_mode = ( $mode == 'post' || $mode == 'reply' || $mode == 'quote' ) ? 'post' : 'topic' ;
2003-04-19 12:58:37 +00:00
markread ( $mark_mode , $post_data [ 'forum_id' ], $post_data [ 'topic_id' ], $post_data [ 'post_id' ]);
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$db -> sql_transaction ( 'commit' );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
// Send Notifications
2003-05-05 22:48:17 +00:00
if ( $mode != 'edit' && $mode != 'delete' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
user_notification ( $mode , stripslashes ( $post_data [ 'subject' ]), $post_data [ 'forum_id' ], $post_data [ 'topic_id' ], $post_data [ 'post_id' ]);
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
2003-05-05 22:48:17 +00:00
meta_refresh ( 3 , " viewtopic. $phpEx $SID &f= " . $post_data [ 'forum_id' ] . '&p=' . $post_data [ 'post_id' ] . '#' . $post_data [ 'post_id' ]);
2003-04-19 12:58:37 +00:00
$message = ( $auth -> acl_get ( 'f_moderate' , $post_data [ 'forum_id' ]) && ! $auth -> acl_get ( 'f_ignorequeue' , $post_data [ 'forum_id' ])) ? 'POST_STORED_MOD' : 'POST_STORED' ;
$message = $user -> lang [ $message ] . '<br /><br />' . sprintf ( $user -> lang [ 'VIEW_MESSAGE' ], '<a href="viewtopic.' . $phpEx . $SID . '&p=' . $post_data [ 'post_id' ] . '#' . $post_data [ 'post_id' ] . '">' , '</a>' ) . '<br /><br />' . sprintf ( $user -> lang [ 'RETURN_FORUM' ], '<a href="viewforum.' . $phpEx . $SID . '&f=' . $post_data [ 'forum_id' ] . '">' , '</a>' );
trigger_error ( $message );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
// User Notification
function user_notification ( $mode , $subject , $forum_id , $topic_id , $post_id )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
global $db , $user , $config , $phpEx ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$topic_notification = ( $mode == 'reply' || $mode == 'quote' ) ? true : false ;
$newtopic_notification = ( $mode == 'post' ) ? true : false ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( empty ( $censors ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$censors = array ();
obtain_word_list ( $censors );
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
// Get banned User ID's
$sql = " SELECT ban_userid
FROM " . BANLIST_TABLE;
$result = $db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$sql_ignore_users = ANONYMOUS . ', ' . $user -> data [ 'user_id' ];
while ( $row = $db -> sql_fetchrow ( $result ))
{
if ( isset ( $row [ 'ban_userid' ]))
{
2003-04-19 17:46:29 +00:00
$sql_ignore_users .= ', ' . $row [ 'ban_userid' ];
2003-04-19 12:58:37 +00:00
}
}
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
//
if ( $topic_notification )
{
$sql = " SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title, f.forum_name
FROM " . TOPICS_WATCH_TABLE . " tw , " . TOPICS_TABLE . " t , " . USERS_TABLE . " u , " . FORUMS_TABLE . " f
WHERE tw . topic_id = $topic_id
AND tw . user_id NOT IN ( $sql_ignore_users )
AND tw . notify_status = 0
AND f . forum_id = $forum_id
AND t . topic_id = tw . topic_id
AND u . user_id = tw . user_id " ;
}
else if ( $newtopic_notification )
{
$sql = " SELECT u.user_id, u.username, u.user_email, u.user_lang, f.forum_name
FROM " . USERS_TABLE . " u , " . FORUMS_WATCH_TABLE . " fw , " . FORUMS_TABLE . " f
WHERE fw . forum_id = $forum_id
AND fw . user_id NOT IN ( $sql_ignore_users )
AND fw . notify_status = 0
AND f . forum_id = fw . forum_id
AND u . user_id = fw . user_id " ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
else
{
trigger_error ( 'WRONG_NOTIFICATION_MODE' );
}
$result = $db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$email_users = array ();
$update_watched_sql_topic = $update_watched_sql_forum = '' ;
//
if ( $row = $db -> sql_fetchrow ( $result ))
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( $topic_notification )
2003-03-22 15:48:46 +00:00
{
2003-04-21 14:13:10 +00:00
decode_text ( $row [ 'topic_title' ]);
$topic_title = ( sizeof ( $censors )) ? preg_replace ( $censors [ 'match' ], $censors [ 'replace' ], $row [ 'topic_title' ]) : $row [ 'topic_title' ];
2003-03-22 15:48:46 +00:00
}
else
{
2003-04-21 14:13:10 +00:00
decode_text ( $subject );
2003-04-19 12:58:37 +00:00
$topic_title = ( sizeof ( $censors )) ? preg_replace ( $censors [ 'match' ], $censors [ 'replace' ], $subject ) : $subject ;
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
$which_sql = ( $topic_notification ) ? 'update_watched_sql_topic' : 'update_watched_sql_forum' ;
do
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( trim ( $row [ 'user_email' ]) != '' )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$row [ 'email_template' ] = ( $topic_notification ) ? 'topic_notify' : 'newtopic_notify' ;
$email_users [] = $row ;
$$which_sql .= ( $$which_sql != '' ) ? ', ' . $row [ 'user_id' ] : $row [ 'user_id' ];
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
while ( $row = $db -> sql_fetchrow ( $result ));
}
// Handle remaining Notifications (Forum)
if ( $topic_notification )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
$already_notified = ( $update_watched_sql_topic == '' ) ? '' : $update_watched_sql_topic . ', ' ;
$already_notified .= ( $update_watched_sql_forum == '' ) ? '' : $update_watched_sql_forum . ', ' ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$sql = " SELECT u.user_id, u.username, u.user_email, u.user_lang, t.topic_title, f.forum_name
FROM " . TOPICS_TABLE . " t , " . USERS_TABLE . " u , " . FORUMS_WATCH_TABLE . " fw , " . FORUMS_TABLE . " f
WHERE fw . forum_id = $forum_id
2003-04-19 17:49:25 +00:00
AND fw . user_id NOT IN ( $already_notified $sql_ignore_users )
2003-04-19 12:58:37 +00:00
AND fw . notify_status = 0
AND t . topic_id = $topic_id
AND f . forum_id = fw . forum_id
AND u . user_id = fw . user_id " ;
$result = $db -> sql_query ( $sql );
if ( $row = $db -> sql_fetchrow ( $result ))
2003-03-22 15:48:46 +00:00
{
2003-04-21 14:13:10 +00:00
$forum_name = $row [ 'forum_name' ];
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
do
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
if ( trim ( $row [ 'user_email' ]) != '' )
2003-04-18 13:07:19 +00:00
{
2003-04-19 12:58:37 +00:00
$row [ 'email_template' ] = 'forum_notify' ;
$email_users [] = $row ;
$update_watched_sql_forum .= ( $update_watched_sql_forum != '' ) ? ', ' . $row [ 'user_id' ] : $row [ 'user_id' ];
2003-04-18 13:07:19 +00:00
}
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
while ( $row = $db -> sql_fetchrow ( $result ));
2003-03-22 15:48:46 +00:00
}
}
2003-04-19 12:58:37 +00:00
// We're going to try and minimise the number of emails we send by using bcc.
// The complication here is that different templates and/or localisations may
// be required so we need to account for these.
if ( sizeof ( $email_users ) && $config [ 'email_enable' ])
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
global $phpbb_root_path , $phpEx ;
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
@ set_time_limit ( 60 );
include ( $phpbb_root_path . 'includes/emailer.' . $phpEx );
$emailer = new emailer ();
$bcc_list_ary = array ();
foreach ( $email_users as $row )
2003-04-21 14:13:10 +00:00
{
$pos = sizeof ( $bcc_list_ary [ $row [ 'email_template' ]][ $row [ 'user_lang' ]]);
$bcc_list_ary [ $row [ 'email_template' ]][ $row [ 'user_lang' ]][ $pos ][ 'email' ] = $row [ 'user_email' ];
$bcc_list_ary [ $row [ 'email_template' ]][ $row [ 'user_lang' ]][ $pos ][ 'name' ] = $row [ 'username' ];
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
unset ( $email_users );
foreach ( $bcc_list_ary as $email_template => $bcc_list )
2003-03-22 15:48:46 +00:00
{
2003-04-19 12:58:37 +00:00
foreach ( $bcc_list as $lang => $bcc )
2003-03-22 15:48:46 +00:00
{
2003-04-21 14:13:10 +00:00
$emailer -> template ( $email_template , $lang );
$emailer -> replyto ( $config [ 'board_email' ]);
foreach ( $bcc as $addr )
{
$emailer -> bcc ( $addr [ 'email' ], $addr [ 'name' ]);
}
2003-04-19 12:58:37 +00:00
$emailer -> assign_vars ( array (
'EMAIL_SIG' => str_replace ( '<br />' , " \n " , " -- \n " . $config [ 'board_email_sig' ]),
'SITENAME' => $config [ 'sitename' ],
2003-04-21 14:13:10 +00:00
'TOPIC_TITLE' => trim ( $topic_title ),
'FORUM_NAME' => trim ( $forum_name ),
2003-04-19 12:58:37 +00:00
'U_TOPIC' => generate_board_url () . 'viewtopic.' . $phpEx . '?t=' . $topic_id . '&p=' . $post_id . '#' . $post_id ,
'U_FORUM' => generate_board_url () . 'viewforum.' . $phpEx . '?f=' . $forum_id ,
'U_STOP_WATCHING_TOPIC' => generate_board_url () . 'viewtopic.' . $phpEx . '?t=' . $topic_id . '&unwatch=topic' ,
'U_STOP_WATCHING_FORUM' => generate_board_url () . 'viewforum.' . $phpEx . '?f=' . $forum_id . '&unwatch=forum' )
);
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
$emailer -> send ();
$emailer -> reset ();
}
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
}
unset ( $bcc_list_ary );
2003-03-22 15:48:46 +00:00
2003-04-19 12:58:37 +00:00
if ( $update_watched_sql_topic != '' )
{
$sql = " UPDATE " . TOPICS_WATCH_TABLE . "
SET notify_status = 1
WHERE topic_id = " . $topic_id . "
AND user_id IN ( " . $update_watched_sql_topic . " ) " ;
$db -> sql_query ( $sql );
2003-03-22 15:48:46 +00:00
}
2003-04-19 12:58:37 +00:00
if ( $update_watched_sql_forum != '' )
{
$sql = " UPDATE " . FORUMS_WATCH_TABLE . "
SET notify_status = 1
WHERE forum_id = " . $forum_id . "
AND user_id IN ( " . $update_watched_sql_forum . " ) " ;
$db -> sql_query ( $sql );
}
2003-03-22 15:48:46 +00:00
}
2002-07-14 14:37:47 +00:00
?>