Guests Can Post v0.20
Authors: xandra
PHP-Fusion Copyright © 2002 - 2005 Nick Jones
Released under the terms & conditions of v2 of the GNU General Public License. For details refer to the included gpl.txt file or visit http://gnu.org
Description:
This mod will allow guests to post in the forum. It also allows guests to enter their name when they post.
Questions?
Post them at http://phpfusion-mods.com or http://www.php-fusion.co.uk.
Installation Instructions:
Backup your website before uploading or modifying any files.
Step 1: Upload the contents of the php-files folder to the appropriate directory.
Step 2: Choose either Option 1 or Option 2 below...
This package may or may not include modified files for your specific php-fusion version.
Do NOT use the modified files from this package if you have modified any of the above files on your site. Instead, follow the mod instructions provided below.
Option 1: If you have not modified any of the above files on your site, you should be able to use the included files without any problems. Check the mod folder to see if there is a folder that corresponds with your php-fusion version number. If so, upload the contents of that folder to the appropriate directories on your site and installation will be complete.
Option 2: If there are no files included for your specific php-fusion version or you have modified any of the above files on your site, you will need to modify your existing files using the mod instructions below.
Step 3: Go to infusions admin and infuse Guests Can Post.
Prevent Attachments By Guests: If you've enabled attachments in the forum settings, then by default, guests will be allowed to attach files to their forum posts just like members can. If you want to prevent this, follow the mod instructions located at the bottom of this page.
Mod Instructions:
The instructions below are for PHP-Fusion v6.00.301, but may work on earlier or later versions.
Colored Code: Throughout the mod instructions, some of the code is colored red and some blue. The colors show the code changes made for this mod... red is the code that's been removed, while blue is the code that's been added. This should help you figure out what needs to be changed if you have previously modified some of the lines in this mod.
Open administration/forums.php
Find and DELETE the red code...
if ($user_group['0'] != "0") {
$sel = ($forum_posting == $user_group['0'] ? " selected" : "");
$posting_opts .= "<option value='".$user_group['0']."'$sel>".$user_group['1']."</option>\n";
}
Save and close.
Open forum/index.php
Find...
$data3 = dbarray(dbquery("SELECT user_name FROM ".$db_prefix."users WHERE user_id='".$data2['forum_lastuser']."'"));
REPLACE with...
if ($data2['forum_lastuser']) {
$data3 = dbarray(dbquery("SELECT user_name FROM ".$db_prefix."users WHERE user_id='".$data2['forum_lastuser']."'"));
} else {
$gcp_data = dbarray(dbquery("SELECT post_id FROM ".$db_prefix."posts
WHERE forum_id='".$data2['forum_id']."' ORDER BY post_id DESC
"));
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='".$gcp_data['post_id']."'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_lastuser = $gcp_data['guest_name'];
} else { $gcp_lastuser = $locale['GCP_001']; }
}
Find...
"<a href='".BASEDIR."profile.php?lookup=".$data2['forum_lastuser']."'>".$data3['user_name']."</a>
REPLACE with...
($data3['user_name'] ? "<a href='".BASEDIR."profile.php?lookup=".$data2['forum_lastuser']."'>".$data3['user_name']."</a>" : $gcp_lastuser)."
Save and close.
Open forum/postnewthread.php
Find...
opentable($locale['400']);
ADD below it...
if (isset($_POST['gcp_name'])) {
$gcp_name = trim(stripinput(censorwords($_POST['gcp_name'])));
if ($gcp_name == "") { $gcp_name = $locale['GCP_001']; }
}
Find...
$userdata['user_name']
REPLACE with...
(iMEMBER ? $userdata['user_name'] : $gcp_name)
Find...
($is_mod ? $locale['userf1'] : getuserlevel($userdata['user_level']))
REPLACE with...
($is_mod ? $locale['userf1'] : (iMEMBER ? getuserlevel($userdata['user_level']) : $locale['GCP_002']))
Find and DELETE...
if (iMEMBER) {
Find...
echo "<span class='alt'>".$locale['423']."</span> ".$userdata['user_posts']."<br>\n";
ADD above it...
if (iMEMBER) {
Find...
echo "<span class='alt'>".$locale['425']."</span> ".showdate("%d.%m.%y", $userdata['user_joined'])."</td>
REPLACE with...
echo "<span class='alt'>".$locale['425']."</span> ".showdate("%d.%m.%y", $userdata['user_joined']);
}
echo "</td>
Find...
$error = "0";
ADD below it...
if (isset($_POST['gcp_name'])) { $gcp_name = trim(stripinput(censorwords($_POST['gcp_name']))); }
Find...
$result = dbquery("UPDATE ".$db_prefix."users SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."'");
REPLACE with...
if (iMEMBER) { $result = dbquery("UPDATE ".$db_prefix."users SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."'"); }
if (!iMEMBER && $gcp_name != "") { dbquery("INSERT INTO ".$db_prefix."gcp_guests VALUES ('$post_id', '$gcp_name')"); }
Find and DELETE...
} else {
$error = "3";
}
Find...
<table width='100%' border='0' cellspacing='1' cellpadding='0'>
REPLACE with...
<table width='100%' border='0' cellspacing='1' cellpadding='0'>";
if (!iMEMBER) {
echo "<tr>
<td align='left' class='tbl2'>".$locale['GCP_003']."</td>
<td align='left' class='tbl1'><input type='text' name='gcp_name' value='$gcp_name' maxlength='30' class='textbox' style='width:250px;'>".$locale['465']."</td>
</tr>";
}
echo "
Save and close.
Open forum/postreply.php
Find...
if (isset($_POST['previewreply'])) {
ADD below it...
if (isset($_POST['gcp_name'])) {
$gcp_name = trim(stripinput(censorwords($_POST['gcp_name'])));
if ($gcp_name == "") { $gcp_name = $locale['GCP_001']; }
}
Find...
$userdata['user_name']
REPLACE with...
(iMEMBER ? $userdata['user_name'] : $gcp_name)
Find...
($is_mod ? $locale['userf1'] : getuserlevel($userdata['user_level']))
REPLACE with...
($is_mod ? $locale['userf1'] : (iMEMBER ? getuserlevel($userdata['user_level']) : $locale['GCP_002']))
Find and delete...
if (iMEMBER) {
Find...
echo "<span class='alt'>".$locale['423']."</span> ".$userdata['user_posts']."<br>\n";
ADD above it...
if (iMEMBER) {
Find...
echo "<span class='alt'>".$locale['425']."</span> ".showdate("%d.%m.%y", $userdata['user_joined'])."</td>
REPLACE with...
echo "<span class='alt'>".$locale['425']."</span> ".showdate("%d.%m.%y", $userdata['user_joined']);
}
echo "</td>
Find...
$error = "0";
ADD below it...
if (isset($_POST['gcp_name'])) { $gcp_name = trim(stripinput(censorwords($_POST['gcp_name']))); }
Find...
$result = dbquery("UPDATE ".$db_prefix."users SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."'");
REPLACE with...
if (iMEMBER) { $result = dbquery("UPDATE ".$db_prefix."users SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."'"); }
if (!iMEMBER && $gcp_name != "") { dbquery("INSERT INTO ".$db_prefix."gcp_guests VALUES ('$newpost_id', '$gcp_name')"); }
Find and DELETE...
} else {
$error = "3";
}
Find...
if (dbrows($result) != "0") {
ADD above it...
if (dbrows($result) == 0) {
$result = dbquery("SELECT * FROM ".$db_prefix."posts WHERE thread_id='$thread_id' and post_id='$quote'");
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='$quote'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_user_name = $gcp_data['guest_name'];
} else { $gcp_user_name = $locale['GCP_001']; }
}
Find...
$data['user_name']
REPLACE with...
($data['user_name'] ? $data['user_name'] : $gcp_user_name)
Find...
<table width='100%' border='0' cellspacing='1' cellpadding='0'>
REPLACE with...
<table width='100%' border='0' cellspacing='1' cellpadding='0'>";
if (!iMEMBER) {
echo "<tr>
<td align='left' class='tbl2'>".$locale['GCP_003']."</td>
<td align='left' class='tbl1'><input type='text' name='gcp_name' value='$gcp_name' maxlength='30' class='textbox' style='width:250px;'>".$locale['465']."</td>
</tr>";
}
echo "
Save and close.
Open forum/viewforum.php
Find...
if (iMEMBER && $can_post) {
REPLACE with...
if ($can_post) {
The line appears twice, so search and replace the above again.
Find...
echo "<td class='tbl1'><img src='".THEME."forum/stickythread.gif' alt='".$locale['560']."' style='vertical-align:middle;'>
ADD above it...
if (!$data['user_author']) {
$gcp_data = dbarray(dbquery("SELECT post_id FROM ".$db_prefix."posts WHERE thread_id='".$data['thread_id']."' ORDER BY post_id ASC"));
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='".$gcp_data['post_id']."'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_author = $gcp_data['guest_name'];
} else { $gcp_author = $locale['GCP_001']; }
}
if (!$data['user_lastuser']) {
$gcp_data = dbarray(dbquery("SELECT post_id FROM ".$db_prefix."posts WHERE thread_id='".$data['thread_id']."' ORDER BY post_id DESC"));
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='".$gcp_data['post_id']."'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_lastuser = $gcp_data['guest_name'];
} else { $gcp_lastuser = $locale['GCP_001']; }
}
Find...
echo "<td class='tbl1'>$threadsubject</td>
ADD above it...
if (!$data['user_author']) {
$gcp_data = dbarray(dbquery("SELECT post_id FROM ".$db_prefix."posts WHERE thread_id='".$data['thread_id']."' ORDER BY post_id ASC"));
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='".$gcp_data['post_id']."'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_author = $gcp_data['guest_name'];
} else { $gcp_author = $locale['GCP_001']; }
}
if (!$data['user_lastuser']) {
$gcp_data = dbarray(dbquery("SELECT post_id FROM ".$db_prefix."posts WHERE thread_id='".$data['thread_id']."' ORDER BY post_id DESC"));
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='".$gcp_data['post_id']."'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_lastuser = $gcp_data['guest_name'];
} else { $gcp_lastuser = $locale['GCP_001']; }
}
Find...
<a href='../profile.php?lookup=".$data['thread_author']."'>".$data['user_author']."</a>
REPLACE with...
".($data['user_author'] ? "<a href='../profile.php?lookup=".$data['thread_author']."'>".$data['user_author']."</a>" : $gcp_author)."
The line appears twice, so search and replace the above again. Note: The code you're searching for is also in the replacement line that you just inserted, so on the second search and replace, be sure you're not replacing the code in the line that you've just inserted.
Find...
"<a href='../profile.php?lookup=".$data['thread_lastuser']."'>".$data['user_lastuser']."</a>
REPLACE with...
($data['user_lastuser'] ? "<a href='../profile.php?lookup=".$data['thread_lastuser']."'>".$data['user_lastuser']."</a>" : $gcp_lastuser)."
The line appears twice, so search and replace the above again. Note: The code you're searching for is also in the replacement line that you just inserted, so on the second search and replace, be sure you're not replacing the code in the line that you've just inserted.
Save and close.
Open forum/viewthread.php
Find...
if (iMEMBER && $can_post && isset($_POST['postquickreply'])) {
REPLACE with...
if ($can_post && isset($_POST['postquickreply'])) {
$gcp_name = stripinput(censorwords($_POST['gcp_name']));
Find...
$result = dbquery("UPDATE ".$db_prefix."users SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."'");
REPLACE with...
if (iMEMBER) { $result = dbquery("UPDATE ".$db_prefix."users SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."'"); }
if (!iMEMBER && $gcp_name != "") { dbquery("INSERT INTO ".$db_prefix."gcp_guests VALUES ('$newpost_id', '$gcp_name')"); }
Find...
if (iMEMBER && $can_post) {
REPLACE with...
if ($can_post) {
The line appears four times, so search and replace the above until you've found them all.
Find...
$is_mod = in_array($data['user_id'], $forum_mods) && $data['user_level'] < "102" ? true : false;
REPLACE with...
$is_mod = $data['user_name'] && in_array($data['user_id'], $forum_mods) && $data['user_level'] < "102" ? true : false;
if (!$data['user_name']) {
$gcp_result = dbquery("SELECT * FROM ".$db_prefix."gcp_guests WHERE guest_post_id='".$data['post_id']."'");
if (dbrows($gcp_result) != 0) {
$gcp_data = dbarray($gcp_result);
$gcp_user_name = $gcp_data['guest_name'];
} else { $gcp_user_name = $locale['GCP_001']; }
}
Find...
<a href='../profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a><br>
REPLACE with...
".($data['user_name'] ? "<a href='../profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a>" : $gcp_user_name)."<br>
Find...
getuserlevel($data['user_level'])
REPLACE with...
($data['user_level'] ? getuserlevel($data['user_level']) : $locale['GCP_002'])
Find...
echo "<span class='alt'>".$locale['502']."</span> ".$data['user_posts']."<br>\n";
ADD above it...
if ($data['user_name']) {
Find...
echo "<span class='alt'>".$locale['504']."</span> ".showdate("%d.%m.%y", $data['user_joined'])."</td>
REPLACE with...
echo "<span class='alt'>".$locale['504']."</span> ".showdate("%d.%m.%y", $data['user_joined']);
}
echo "</td>
Find...
$data['user_name'].$locale['506']
REPLACE with...
($data['user_name'] ? $data['user_name'] : $gcp_user_name).$locale['506']
Find...
$data['user_name'].$locale['507']
REPLACE with...
($data['user_name'] ? $data['user_name'] : $gcp_user_name).$locale['507']
Find...
echo "<a href='".BASEDIR."messages.php?msg_send=".$data['user_id']."'><img src='".THEME."forum/pm.gif' alt='".$locale['571']."' style='border:0px;'></a>
REPLACE with...
if ($data['user_id']) {
echo "<a href='".BASEDIR."messages.php?msg_send=".$data['user_id']."'><img src='".THEME."forum/pm.gif' alt='".$locale['571']."' style='border:0px;'></a>";
}
echo "
Find...
if (iMEMBER && $can_post && !$tdata['thread_locked']) {
REPLACE with...
if ($can_post && !$tdata['thread_locked']) {
Find...
<table align='center' cellpadding='0' cellspacing='1' class='tbl-border'>
REPLACE with...
<table align='center' cellpadding='0' cellspacing='1' class='tbl-border'>";
if (!iMEMBER) {
echo "<tr>
<td align='left' class='tbl2'>".$locale['GCP_003']."<input type='text' name='gcp_name' value='$gcp_name' maxlength='30' class='textbox' style='width:250px;'> ".$locale['GCP_004']."</td>
</tr>";
}
echo "
Save and close.
Open locale/English/forums/main.php
Find...
?>
ADD above it...
// Guests Can Post Mod
$locale['GCP_001'] = "Guest";
$locale['GCP_002'] = "Unregistered";
$locale['GCP_003'] = "Name: ";
$locale['GCP_004'] = "(Optional)";
Save and close.
Open locale/English/forums/post.php
Find...
?>
ADD above it...
// Guests Can Post Mod
$locale['GCP_001'] = "Guest";
$locale['GCP_002'] = "Unregistered";
$locale['GCP_003'] = "Name";
Save and close.
Prevent Attachments By Guests:
Follow the instructions below if you'd like to prevent guests from adding attachments to their posts. These instructions are for PHP-Fusion v6.00.300, but may work on earlier or later versions.
Open forum/postnewthread.php and forum/postreply.php
Instructions are the same for both files...
Find...
$attach = $_FILES['attach'];
ADD above it...
if (iMEMBER) {
Find...
$error = "1";
ADD below it...
}
Find...
if ($settings['attachments'] == "1") {
REPLACE with...
if (iMEMBER && $settings['attachments'] == "1") {
Save and close.
Change Log: