1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-07 16:15:22 +02:00

Moved signature attach toggle to DB run convert_sig to update after adding new field to DB

git-svn-id: file:///svn/phpbb/trunk@998 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-09-07 00:23:40 +00:00
parent da87531f2f
commit 6695be87e8
4 changed files with 139 additions and 43 deletions

View File

@ -216,6 +216,7 @@ CREATE TABLE phpbb_posts (
enable_bbcode tinyint(1) DEFAULT '1' NOT NULL,
enable_html tinyint(1) DEFAULT '0' NOT NULL,
enable_smilies tinyint(1) DEFAULT '1' NOT NULL,
enable_sig tinyint(1) DEFAULT '1' NOT NULL,
bbcode_uid char(10) NOT NULL,
post_edit_time int(11),
post_edit_count smallint(6) DEFAULT '0' NOT NULL,
@ -255,6 +256,7 @@ CREATE TABLE phpbb_privmsgs (
privmsgs_enable_bbcode tinyint(1) DEFAULT '1' NOT NULL,
privmsgs_enable_html tinyint(1) DEFAULT '0' NOT NULL,
privmsgs_enable_smilies tinyint(1) DEFAULT '1' NOT NULL,
privmsgs_enable_sig tinyint(1) DEFAULT '1' NOT NULL,
privmsgs_bbcode_uid char(10) DEFAULT '0' NOT NULL,
PRIMARY KEY (privmsgs_id),
KEY privmsgs_from_userid (privmsgs_from_userid),

View File

@ -0,0 +1,81 @@
<?
$phpbb_root_path = "../";
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'config.'.$phpEx);
include($phpbb_root_path . 'includes/constants.'.$phpEx);
include($phpbb_root_path . 'includes/db.'.$phpEx);
$sql = "SELECT post_id, post_text
FROM " . POSTS_TEXT_TABLE;
if( $result = $db->sql_query($sql) )
{
$rowset = $db->sql_fetchrowset($result);
$attach_sql = "";
$non_attach_sql = "";
for($i = 0; $i < count($rowset); $i++)
{
if( ereg("\[addsig]$", $rowset[$i]['post_text']))
{
if( $attach_sql != "" )
{
$attach_sql .= ", ";
}
$attach_sql .= $rowset[$i]['post_id'];
$sql = "UPDATE " . POSTS_TEXT_TABLE . "
SET post_text = '" . addslashes(preg_replace("/\[addsig\]/is", "", $rowset[$i]['post_text'])) . "'
WHERE post_id = " . $rowset[$i]['post_id'];
if( !$result = $db->sql_query($sql) )
{
die("Couldn't update post_text - " . $i);
}
}
else
{
if( $non_attach_sql != "" )
{
$non_attach_sql .= ", ";
}
$non_attach_sql .= $rowset[$i]['post_id'];
}
}
echo "<BR>";
if( $attach_sql != "" )
{
echo $sql = "UPDATE " . POSTS_TABLE . "
SET enable_sig = 1
WHERE post_id IN ($attach_sql)";
if( !$result = $db->sql_query($sql) )
{
die("Couldn't update post table attach_sig - ");
}
}
echo "<BR>";
if( $non_attach_sql != "" )
{
echo $sql = "UPDATE " . POSTS_TABLE . "
SET enable_sig = 0
WHERE post_id IN ($non_attach_sql)";
if( !$result = $db->sql_query($sql) )
{
die("Couldn't update post table non_attach_sig - ");
}
}
}
$db->sql_close();
echo "<BR><BR>COMPLETE<BR>";
?>

View File

@ -30,8 +30,8 @@ include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
// Do some initial checks, set basic variables,
// etc.
//
$html_entities_match = array("#<#", "#>#", "#& #");
$html_entities_replace = array("&lt;", "&gt;", "&amp; ");
$html_entities_match = array("#<#", "#>#", "#& #", "#\"#");
$html_entities_replace = array("&lt;", "&gt;", "&amp; ", "&quot;");
$submit = ( isset($HTTP_POST_VARS['submit']) ) ? TRUE : 0;
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : 0;
@ -93,20 +93,21 @@ if( $cancel )
{
if($post_id != "")
{
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id"));
$redirect = "viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id";
}
else if($topic_id != "")
{
header("Location: " . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"));
$redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
}
else if($forum_id != "")
{
header("Location: " . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"));
$redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
}
else
{
header("Location: " . append_sid("index.$phpEx"));
$redirect = "index.$phpEx";
}
header("Location:" . append_sid($redirect));
}
//
// Continue var definitions
@ -510,10 +511,6 @@ if( $submit && $mode != "vote" )
$post_message = prepare_message($HTTP_POST_VARS['message'], $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
if( $attach_sig )
{
$post_message .= (ereg(" $", $post_message)) ? "[addsig]" : " [addsig]";
}
}
}
else
@ -694,8 +691,8 @@ if( ( $submit || $confirm ) && !$error )
$new_topic_id = $topic_id;
}
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, bbcode_uid, enable_bbcode, enable_html, enable_smilies)
VALUES ($new_topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '$user_ip', '$bbcode_uid', $bbcode_on, $html_on, $smilies_on)";
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, bbcode_uid, enable_bbcode, enable_html, enable_smilies, enable_sig)
VALUES ($new_topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '$user_ip', '$bbcode_uid', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
$result = ($mode == "reply") ? $db->sql_query($sql, BEGIN_TRANSACTION) : $db->sql_query($sql);
if($result)
@ -1191,7 +1188,7 @@ if( ( $submit || $confirm ) && !$error )
}
$sql = "UPDATE " . POSTS_TABLE . "
SET bbcode_uid = '$bbcode_uid', enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on" . $edited_sql . "
SET bbcode_uid = '$bbcode_uid', enable_bbcode = $bbcode_on, enable_html = $html_on, enable_smilies = $smilies_on, enable_sig = $attach_sig" . $edited_sql . "
WHERE post_id = $post_id";
if($db->sql_query($sql, BEGIN_TRANSACTION))
@ -1505,7 +1502,7 @@ else if( $preview || $refresh || $error )
@reset($HTTP_POST_VARS['poll_option_text']);
while( list($option_id, $option_text) = each($HTTP_POST_VARS['poll_option_text']) )
{
$poll_option_list[$option_id] = trim(strip_tags(stripslashes($option_text)));
$poll_option_list[$option_id] = trim(strip_tags(preg_replace($html_entities_match, $html_entities_replace, stripslashes($option_text))));
$poll_options++;
}
}
@ -1655,17 +1652,16 @@ else
$post_subject = $postrow['post_subject'];
$post_message = $postrow['post_text'];
if( eregi("\[addsig]$", $post_message) )
if( $mode == "editpost" )
{
$post_message = eregi_replace("\[addsig]$", "", $post_message);
$attach_sig = ( $mode == "editpost" ) ? ( ( $postrow['user_sig'] != "" ) ? TRUE : 0 ) : ( ( $userdata['user_sig'] != "" ) ? TRUE : 0 );
$attach_sig = ( $postrow['enable_sig'] && $postrow['user_sig'] != "" ) ? TRUE : 0;
$user_sig = $postrow['user_sig'];
}
else
{
$attach_sig = ( $mode == "editpost" ) ? 0 : ( ( $userdata['user_sig'] != "" ) ? TRUE : 0 );
$attach_sig = ( $userdata['user_attachsig'] ) ? TRUE : 0;
$user_sig = $userdata['user_sig'];
}
$user_sig = ( $attach_sig ) ? ( ( $mode == "editpost" ) ? $postrow['user_sig'] : $userdata['user_sig'] ) : "";
$post_message = preg_replace("/\:[0-9a-z\:]*?\]/si", "]", $post_message);
$post_message = str_replace("<br />", "\n", $post_message);
@ -1712,12 +1708,16 @@ else
}
$vote_results_sum = 0;
while( $row = $db->sql_fetchrow($result) )
if( $row = $db->sql_fetchrow($result) )
{
$poll_title = $row['vote_text'];
$poll_length = $row['vote_length'];
$poll_option_list[$row['vote_option_id']] = $row['vote_option_text'];
while( $row = $db->sql_fetchrow($result) )
{
$poll_option_list[$row['vote_option_id']] = $row['vote_option_text'];
}
}
$poll_length = $poll_length / 86400;
@ -1809,7 +1809,7 @@ if( $preview && !$error )
}
}
if( $user_sig != "" && $board_config['allow_bbcode'] )
if( $attach_sig && $user_sig != "" && $board_config['allow_bbcode'] )
{
$sig_uid = make_bbcode_uid();
$user_sig = bbencode_first_pass($user_sig, $sig_uid);
@ -1855,11 +1855,6 @@ if( $preview && !$error )
);
$template->pparse("preview");
//
// Post preview output conversion
//
$post_message = preg_replace($html_entities_match, $html_entities_replace, $post_message);
}
//
// End preview output
@ -2018,13 +2013,13 @@ switch($mode)
// Output the data to the template
//
$template->assign_vars(array(
"USERNAME" => $post_username,
"SUBJECT" => $post_subject,
"USERNAME" => preg_replace($html_entities_match, $html_entities_replace, $post_username),
"SUBJECT" => preg_replace($html_entities_match, $html_entities_replace, $post_subject),
"MESSAGE" => $post_message,
"HTML_STATUS" => $html_status,
"BBCODE_STATUS" => $bbcode_status,
"SMILIES_STATUS" => $smilies_status,
"POLL_TITLE" => $poll_title,
"POLL_TITLE" => preg_replace($html_entities_match, $html_entities_replace, $poll_title),
"POLL_LENGTH" => $poll_length,
"L_SUBJECT" => $lang['Subject'],
@ -2086,7 +2081,7 @@ if( $display_poll )
while( list($option_id, $option_text) = each($poll_option_list) )
{
$template->assign_block_vars("poll_option_rows", array(
"POLL_OPTION" => $option_text,
"POLL_OPTION" => preg_replace($html_entities_match, $html_entities_replace, $option_text),
"S_POLL_OPTION_NUM" => $option_id)
);

View File

@ -332,7 +332,7 @@ $select_post_order .= "</select>";
//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, p.post_time, p.post_id, p.post_username, p.bbcode_uid, p.post_edit_time, p.post_edit_count, p.enable_bbcode, p.enable_html, p.enable_smilies, pt.post_text, pt.post_subject
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, p.*, pt.post_text, pt.post_subject
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
@ -519,6 +519,11 @@ if( !empty($forum_row['topic_vote']) )
$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
if( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$template->assign_block_vars("poll_option", array(
"POLL_OPTION_CAPTION" => $vote_info[$i]['vote_option_text'],
"POLL_OPTION_RESULT" => $vote_info[$i]['vote_result'],
@ -542,6 +547,11 @@ if( !empty($forum_row['topic_vote']) )
for($i = 0; $i < $vote_options; $i++)
{
if( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$template->assign_block_vars("poll_option", array(
"POLL_OPTION_ID" => $vote_info[$i]['vote_option_id'],
"POLL_OPTION_CAPTION" => $vote_info[$i]['vote_option_text'])
@ -558,6 +568,11 @@ if( !empty($forum_row['topic_vote']) )
$s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '"><input type="hidden" name="mode" value="vote">';
}
if( count($orig_word) )
{
$vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
}
$template->assign_vars(array(
"POLL_QUESTION" => $vote_title,
@ -672,7 +687,7 @@ for($i = 0; $i < $total_posts; $i++)
$aim_img = ($postrow[$i]['user_aim']) ? "<a href=\"aim:goim?screenname=" . stripslashes($postrow[$i]['user_aim']) . "&amp;message=Hello+Are+you+there?\"><img src=\"" . $images['icon_aim'] . "\" border=\"0\" alt=\"" . $lang['AIM'] . "\" /></a>" : "";
$msn_img = ($postrow[$i]['user_msnm']) ? "<a href=\"profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id\"><img src=\"" . $images['icon_msnm'] . "\" border=\"0\" alt=\"" . $lang['MSNM'] . "\" /></a>" : "";
$msn_img = ($postrow[$i]['user_msnm']) ? "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"" . $images['icon_msnm'] . "\" border=\"0\" alt=\"" . $lang['MSNM'] . "\" /></a>" : "";
$yim_img = ($postrow[$i]['user_yim']) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=" . $postrow[$i]['user_yim'] . "&amp;.src=pg\"><img src=\"" . $images['icon_yim'] . "\" border=\"0\" alt=\"" . $lang['YIM'] . "\" /></a>" : "";
}
@ -704,7 +719,7 @@ for($i = 0; $i < $total_posts; $i++)
if( $is_auth['auth_mod'] )
{
$ip_img = "<a href=\"" . append_sid("modcp.$phpEx?mode=viewip&amp;" . POST_POST_URL . "=" . $post_id) . "\"><img src=\"" . $images['icon_ip'] . "\" alt=\"" . $lang['View_IP'] . "\" border=\"0\" /></a>";
$ip_img = "<a href=\"" . append_sid("modcp.$phpEx?mode=viewip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_ip'] . "\" alt=\"" . $lang['View_IP'] . "\" border=\"0\" /></a>";
$delpost_img = "<a href=\"" . append_sid("topicadmin.$phpEx?mode=delpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_delpost'] . "\" alt=\"" . $lang['Delete_post'] . "\" border=\"0\" /></a>";
}
@ -727,7 +742,7 @@ for($i = 0; $i < $total_posts; $i++)
//
if( !$board_config['allow_html'] )
{
if($user_sig != "")
if( $user_sig != "" && $postrow[$i]['enable_sig'] )
{
$user_sig = preg_replace("#(<)([\/]?.*?)(>)#is", "&lt;\\2&gt;", $user_sig);
}
@ -740,7 +755,7 @@ for($i = 0; $i < $total_posts; $i++)
if( $board_config['allow_bbcode'] && $bbcode_uid != "" )
{
if($user_sig != "")
if( $user_sig != "" && $postrow[$i]['enable_sig'] )
{
$sig_uid = make_bbcode_uid();
$user_sig = bbencode_first_pass($user_sig, $sig_uid);
@ -754,7 +769,10 @@ for($i = 0; $i < $total_posts; $i++)
$message = preg_replace("/\:[0-9a-z\:]+\]/si", "]", $message);
}
$message = ($user_sig != "") ? ereg_replace("\[addsig]$", "<br /><br />_________________<br />" . $user_sig, $message) : ereg_replace("\[addsig]$", "", $message);
if( $postrow[$i]['enable_sig'] )
{
$message .= "<br /><br />_________________<br />" . $user_sig;
}
if( count($orig_word) )
{
@ -865,13 +883,13 @@ if($can_watch_topic)
{
if($is_watching_topic)
{
$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start\">" . $lang['Stop_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>";
$s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . "\">" . $lang['Stop_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start") . "\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>";
}
else
{
$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start\">" . $lang['Start_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>";
$s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . "\">" . $lang['Start_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start") . "\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>";
}
}
else