1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-31 19:49:20 +02:00

Started on posting.php, got the logic done for displaying the new topic form

git-svn-id: file:///svn/phpbb/trunk@83 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
James Atkinson 2001-03-07 06:53:39 +00:00
parent 231c945e35
commit 9ef35696d2
8 changed files with 299 additions and 76 deletions

View File

@ -31,7 +31,7 @@ unset($ip);
include('template.inc');
// Setup what template to use. Currently just use default
$template = new Template("./templates/Default", "keep");
$template = new Template("./templates/Default", "remove");
include('functions/error.'.$phpEx);
include('functions/sessions.'.$phpEx);

View File

@ -40,8 +40,8 @@ define(PUBLIC, 1);
define(PRIVATE, 2);
// Forum posting levels
define(ANONALLOWED, 1);
define(REGONLY, 2);
define(ANONALLOWED, 2);
define(REGONLY, 1);
define(MODONLY, 3);
// Topic state

View File

@ -270,8 +270,10 @@ $l_htmlis = "$l_html is";
$l_bbcodeis = "$l_bbcode is";
$l_notify = "Notify by email when replies are posted";
// "
// Newtopic
$l_postnew = "Post New Topic";
$l_postnewin = "Post New Topic in:";
$l_emptymsg = "You must type a $l_message to post. You cannot post an empty $l_message.";
$l_aboutpost = "About Posting";
$l_regusers = "All <b>Registered</b> users";
@ -279,9 +281,9 @@ $l_anonusers = "<b>Anonymous</b> users";
$l_modusers = "Only <B>Moderators and Administrators</b>";
$l_anonhint = "<br>(To post anonymously simply do not enter a username and password)";
$l_inthisforum = "can post new topics and replies to this forum";
$l_attachsig = "Show signature <font size=-2>(This can be altered or added in your profile)</font>";
$l_attachsig = "Show signature (This can be altered or added in your profile)";
$l_cancelpost = "Cancel Post";
$l_preview = "Preview Post";
// Reply
$l_nopostlock = "You cannot post a reply to this topic, it has been locked.";
$l_topicreview = "Topic Review";

View File

@ -121,7 +121,14 @@ switch($pagetype)
"TOPIC_TITLE" => $topic_title));
$template->pparse("output", "header");
break;
case 'newtopic':
$template->set_file(array("header" => "newtopic_header.tpl",
"body" => "posting_body.tpl"));
$template->set_var(array("FORUM_ID" => $forum_id,
"FORUM_NAME" => $forum_name,
"L_POSTNEWIN" => $l_postnewin));
$template->pparse("output", "header");
break;
}
?>

View File

@ -1,6 +1,6 @@
<?php
/***************************************************************************
*
* posting.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
@ -21,7 +21,158 @@
*
*
***************************************************************************/
include('extension.inc');
include('common.'.$phpEx);
if($submit && !$preview)
{
switch($mode)
{
case 'newtopic':
echo "Dave likes to submit<br>";
break;
case 'reply':
break;
case 'editpost':
break;
}
}
else
{
switch($mode)
{
case 'newtopic':
if(!isset($forum_id))
{
error_die($db, GENERAL_ERROR, "Sorry, no there is no such forum");
}
$pagetype = "newtopic";
$page_title = " $l_postnew";
$sql = "SELECT forum_name, forum_access FROM forums WHERE forum_id = '$forum_id'";
if(!$result = $db->sql_query($sql))
{
error_die($db, QUERY_ERROR);
}
$forum_info = $db->sql_fetchrowset($result);
$forum_name = stripslashes($forum_info[0]["forum_name"]);
$forum_access = $forum_info[0]["forum_access"];
if($forum_access == ANONALLOWED)
{
$about_posting = "$l_anonusers $l_inthisforum $l_anonhint";
}
if($forum_access == REGONLY)
{
$about_posting = "$l_regusers $l_inthisforum";
}
if($forum_access == MODONLY)
{
$about_posting = "$l_modusers $l_inthisforum";
}
include('page_header.'.$phpEx);
if($user_logged_in)
{
$username_input = $userdata["username"];
$password_input = "";
}
else
{
if(!isset($username))
{
$username = $userdata["username"];
}
$username_input = '<input type="text" name="username" value="'.$username.'" size="25" maxlength="50">';
$password_input = '<input type="password" name="password" size="25" maxlenght="40">';
$subject_input = '<input type="text" name="subject" value="'.$subject.'" size="50" maxlenght="255">';
$message_input = '<textarea name="message" rows="10" cols="35" wrap="virtual">'.$message.'</textarea>';
if($allow_html)
{
$html_status = $l_htmlis . " " . $l_on;
$html_toggle = '<input type="checkbox" name="disable_html" ';
if($disable_html)
{
$html_toggle .= 'checked';
}
$html_toggle .= "> $l_disable $l_html $l_onthispost";
}
else
{
$html_status = $l_htmlis . " " . $l_off;
}
if($allow_bbcode)
{
$bbcode_status = $l_bbcodeis . " " . $l_on;
$bbcode_toggle = '<input type="checkbox" name="disable_bbcode" ';
if($disable_bbcode)
{
$bbcode_toggle .= "checked";
}
$bbcode_toggle .= "> $l_disable $l_bbcode $l_onthispost";
}
else
{
$bbcode_status = $l_bbcodeis . " " . $l_off;
}
$smile_toggle = '<input type="checkbox" name="disable_smile" ';
if($disable_smile)
{
$smile_toggle .= "checked";
}
$smile_toggle .= "> $l_disable $l_smilies $l_onthispost";
$sig_toggle = '<input type="checkbox" name="attach_sig" ';
if($attach_sig || $userdata["attach_sig"] == 1)
{
$sig_toggle .= "checked";
}
$sig_toggle .= "> $l_attachsig";
$notify_toggle = '<input type="checkbox" name="notify" ';
if($notify || $userdata["always_notify"] == 1)
{
$notify_toggle .= "checked";
}
$notify_toggle .= "> $l_notify";
}
$template->set_var(array("L_ABOUTPOST" => $l_aboutpost,
"L_SUBJECT" => $l_subject,
"L_MESSAGEBODY" => $l_body,
"L_OPTIONS" => $l_options,
"L_PREVIEW" => $l_preview,
"L_SUBMIT" => $l_submit,
"L_CANCEL" => $l_cancelpost,
"MODE" => $mode,
"ABOUT_POSTING" => $about_posting,
"USERNAME_INPUT" => $username_input,
"PASSWORD_INPUT" => $password_input,
"SUBJECT_INPUT" => $subject_input,
"MESSAGE_INPUT" => $message_input,
"HTML_STATUS" => $html_status,
"HTML_TOGGLE" => $html_toggle,
"SMILE_TOGGLE" => $smile_toggle,
"SIG_TOGGLE" => $sig_toggle,
"NOTIFY_TOGGLE" => $notify_toggle,
"BBCODE_TOGGLE" => $bbcode_toggle,
"BBCODE_STATUS" => $bbcode_status));
$template->pparse("output", "body");
include('page_tail.'.$phpEx);
break;
case 'reply':
break;
case 'editpost':
break;
}
}
?>

View File

@ -0,0 +1,18 @@
<tr>
<td>
<table border="0" align="right" width="20%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" bgcolor="#CCCCCC" cellpadding="1" cellspacing="1">
<tr>
<td align="center" style="{font-size: 8pt;}">
{L_POSTNEWIN}<br>
<a href="viewforum.{PHPEX}?forum_id={FORUM_ID}">{FORUM_NAME}</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

View File

@ -0,0 +1,47 @@
<tr>
<td><form action="posting.{PHPEX}" method="POST">
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr class="tablebody">
<td bgcolor="#DDDDDD" width="15%">{L_ABOUTPOST}</td>
<td bgcolor="#CCCCCC">{ABOUT_POSTING}</td>
</tr>
<tr class="tablebody">
<td bgcolor="#DDDDDD">{L_USERNAME}</td>
<td bgcolor="#CCCCCC">{USERNAME_INPUT}</td>
</tr>
<tr class="tablebody">
<td bgcolor="#DDDDDD">{L_PASSWORD}</td>
<td bgcolor="#CCCCCC">{PASSWORD_INPUT}</td>
</tr>
<tr class="tablebody">
<td bgcolor="#DDDDDD">{L_SUBJECT}</td>
<td bgcolor="#CCCCCC">{SUBJECT_INPUT}</td>
</tr>
<tr class="tablebody">
<td bgcolor="#DDDDDD">{L_MESSAGEBODY}<br><br>
{HTML_STATUS}<br>{BBCODE_STATUS}</td>
<td bgcolor="#CCCCCC">{MESSAGE_INPUT}</td>
</tr>
<tr class="tablebody">
<td bgcolor="#DDDDDD">{L_OPTIONS}</td>
<td bgcolor="#CCCCCC">
{HTML_TOGGLE}<br>{BBCODE_TOGGLE}<br>{SMILE_TOGGLE}<br>{SIG_TOGGLE}<br>{NOTIFY_TOGGLE}</td>
</tr>
<tr class="tableheader">
<td align="center" colspan="2">
<input type="hidden" name="mode" value="{MODE}">
<input type="hidden" name="forum_id" value="{FORUM_ID}">
<input type="hidden" name="topic_id" value="{TOPIC_ID}">
<input type="submit" name="preview" value="{L_PREVIEW}">&nbsp;
<input type="submit" name="submit" value="{L_SUBMIT}">&nbsp;
<input type="submit" name="cancel" value="{L_CANCEL}"></td>
</tr>
</table>
</td>
</tr>
</table>
</form></td>
</tr>

View File

@ -1,48 +1,48 @@
<?php
/***************************************************************************
/***************************************************************************
* viewtopic.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id$
*
*
***************************************************************************/
* -------------------
* 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.
*
*
***************************************************************************/
include('extension.inc');
/***************************************************************************
*
* 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.
*
*
***************************************************************************/
include('extension.inc');
include('common.'.$phpEx);
$is_moderator = 0;
if(!isset($forum_id) || !isset($topic_id))
{
error_die($db, GENERAL_ERROR, "You have reached this page in error, please go back and try again");
error_die($db, GENERAL_ERROR, "You have reached this page in error, please go back and try again");
}
$sql = "SELECT f.forum_type, u.username, u.user_id
FROM ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE f.forum_id = '$forum_id'
AND fm.forum_id = '$forum_id'
AND u.user_id = fm.user_id";
$sql = "SELECT f.forum_type, f.forum_name, u.username, u.user_id
FROM ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE f.forum_id = '$forum_id'
AND fm.forum_id = '$forum_id'
AND u.user_id = fm.user_id";
if(!$result = $db->sql_query($sql))
{
{
error_die($db, QUERY_ERROR);
}
//
// Add checking for private forums here
//
//
if(!$total_rows = $db->sql_numrows($result))
{
@ -50,6 +50,7 @@ if(!$total_rows = $db->sql_numrows($result))
}
$forum_row = $db->sql_fetchrowset($result);
$forum_name = stripslashes($forum_row[0]["forum_name"]);
for($x = 0; $x < $total_rows; $x++)
{
$moderators[] = array("user_id" => $forum_row[$x]["user_id"],
@ -64,19 +65,18 @@ if(!isset($start))
{
$start = 0;
}
$sql = "SELECT t.topic_title, t.topic_status, t.topic_replies, f.forum_name
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f
WHERE t.topic_id = '$topic_id' AND f.forum_id = t.forum_id";
$sql = "SELECT topic_title, topic_status, topic_replies
FROM ".TOPICS_TABLE."
WHERE topic_id = '$topic_id'";
if(!$result = $db->sql_query($sql))
{
error_die($db, QUERY_ERROR);
error_die($db, QUERY_ERROR);
}
if(!$topic_info = $db->sql_fetchrowset($result))
{
error_die($db, GENERAL_ERROR, "Could not get topic data<br>$sql");
error_die($db, GENERAL_ERROR, "Could not get topic data<br>$sql");
}
$forum_name = stripslashes($topic_info[0]["forum_name"]);
$topic_title = stripslashes($topic_info[0]["topic_title"]);
$total_replies = $topic_info[0]["topic_replies"] + 1;
@ -84,14 +84,15 @@ $pagetype = "viewtopic";
$page_title = "View Topic - $topic_title";
include('page_header.'.$phpEx);
$sql = "SELECT u.*, r.rank_title, r.rank_image,
p.post_time, p.post_id, pt.post_text
FROM ".POSTS_TABLE." p
LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id
LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id) AND NOT (u.user_posts > r.rank_min AND u.user_posts < r.rank_max)
LEFT JOIN ".POSTS_TEXT_TABLE." pt ON p.post_id = pt.post_id
WHERE p.topic_id = '$topic_id'
ORDER BY p.post_time ASC LIMIT $start, $posts_per_page";
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_icq, u.user_aim, u.user_yim,
u.user_regdate, u.user_msnm, u.user_viewemail, r.rank_title, r.rank_image,
p.post_time, p.post_id, pt.post_text
FROM ".POSTS_TABLE." p
LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id
LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id) AND NOT (u.user_posts > r.rank_min AND u.user_posts < r.rank_max)
LEFT JOIN ".POSTS_TEXT_TABLE." pt ON p.post_id = pt.post_id
WHERE p.topic_id = '$topic_id'
ORDER BY p.post_time ASC LIMIT $start, $posts_per_page";
if(!$result = $db->sql_query($sql))
{
@ -99,20 +100,20 @@ if(!$result = $db->sql_query($sql))
}
if(!$total_posts = $db->sql_numrows($result))
{
error_die($db, GENERAL_ERROR, "Error getting post data.");
error_die($db, GENERAL_ERROR, "Error getting post data.");
}
$postrow = $db->sql_fetchrowset($result);
$template->set_block("body", "postrow", "posts");
for($x = 0; $x < $total_posts; $x++)
for($x = 0; $x < $total_posts; $x++)
{
$poster = stripslashes($postrow[$x]["username"]);
$poster_id = $postrow[$x]["user_id"];
$poster_rank = stripslashes($postrow[$x]["rank_title"]);
$rank_image = ($postrow[$x]["rank_image"]) ? "<img src=\"".$postrow[$x]["rank_image"]."\">" : "";
$post_date = date($date_format, $postrow[$x]["post_time"]);
$poster_posts = $postrow[$x]["user_posts"];
$poster_from = ($postrow[$x]["user_from"]) ? "$l_from: ".$postrow[$x]["user_from"] : "";
$poster_joined = $postrow[$x]["user_regdate"];
@ -132,18 +133,18 @@ for($x = 0; $x < $total_posts; $x++)
$icq_add_img = "";
}
$aim_img = ($postrow[$x]["user_aim"]) ? "<a href=\"aim:goim?screenname=".$postrow[$x]["user_aim"]."&message=Hello+Are+you+there?\"><img src=\"$image_aim\" border=\"0\"></a>" : "";
$msn_img = ($postrow[$x]["user_msn"]) ? "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"$image_msn\" border=\"0\"></a>" : "";
$msn_img = ($postrow[$x]["user_msnm"]) ? "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"$image_msn\" border=\"0\"></a>" : "";
$yim_img = ($postrow[$x]["user_yim"]) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$postrow[$x]["user_yim"]."&.src=pg\"><img src=\"$image_yim\" border=\"0\"></a>" : "";
$edit_img = "<a href=\"posting.$phpEx?mode=editpost&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"$image_edit\" alt=\"$l_editdelete\" border=\"0\"></a>";
$quote_img = "<a href=\"posting.$phpEx?mode=reply&quote=true&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"$image_quote\" alt=\"$l_replyquote\" border=\"0\"></a>";
$pmsg_img = "<a href=\"priv_msgs.$phpEx?mode=send\"><img src=\"$image_pmsg\" alt=\"$l_sendpmsg\" border=\"0\"></a>";
if($is_moderator)
if($is_moderator)
{
$ip_img = "<a href=\"topicadmin.$phpEx?mode=viewip&user_id=".$poster_id."\"><img src=\"$image_ip\" alt=\"$l_viewip\" border=\"0\"></a>";
$delpost_img = "<a href=\"topicadmin.$phpEx?mode=delpost$post_id=".$postrow[$x]["post_id"]."\"><img src=\"$image_delpost\" alt=\"$l_delete\" border=\"0\"></a>";
}
$message = stripslashes($postrow[$x]["post_text"]);
if(!$allow_html)
{
@ -153,7 +154,7 @@ for($x = 0; $x < $total_posts; $x++)
{
// do bbcode stuff here
}
if(!($x % 2))
{
$color = "#DDDDDD";
@ -162,7 +163,7 @@ for($x = 0; $x < $total_posts; $x++)
{
$color = "#CCCCCC";
}
$message = eregi_replace("\[addsig]$", "<BR>_________________<BR>" . stripslashes($postrow[$x]["user_sig"]), $message);
$template->set_var(array("TOPIC_TITLE" => $topic_title,
@ -193,44 +194,44 @@ for($x = 0; $x < $total_posts; $x++)
$template->parse("posts", "postrow", true);
}
if($total_replies > $posts_per_page)
if($total_replies > $posts_per_page)
{
$times = 0;
for($x = 0; $x < $total_replies; $x += $posts_per_page)
{
{
$times++;
}
$pages = $times . " pages";
$times = 1;
$pagination = "$l_gotopage (";
$last_page = $start - $posts_per_page;
if($start > 0)
if($start > 0)
{
$pagination .= "<a href=\"$PHP_SELF?topic_id=$topic_id&forum_id=$forum_id&start=$last_page\">$l_prevpage</a> ";
}
for($x = 0; $x < $total_replies; $x += $posts_per_page)
for($x = 0; $x < $total_replies; $x += $posts_per_page)
{
if($times != 1)
if($times != 1)
{
$pagination .= " | ";
}
if($start && ($start == $x))
if($start && ($start == $x))
{
$pagination .= $times;
}
else if($start == 0 && $x == 0)
else if($start == 0 && $x == 0)
{
$pagination .= "1";
}
else
else
{
$pagination .= "<a href=\"$PHP_SELF?topic_id=$topic_id&forum_id=$forum_id&start=$x\">$times</a>";
}
$times++;
}
if(($start + $posts_per_page) < $total_replies)
$times++;
}
if(($start + $posts_per_page) < $total_replies)
{
$next_page = $start + $posts_per_page;
$pagination .= " <a href=\"$PHP_SELF?topic_id=$topic_id&forum_id=$forum_id&start=$next_page\">$l_nextpage</a>";
@ -245,9 +246,6 @@ $template->set_var(array("PAGES" => $pages,
"PAGINATION" => $pagination));
$template->pparse("output", array("posts", "body"));
include('page_tail.'.$phpEx);
include('page_tail.'.$phpEx);
?>