Only let logged in users leave comments

djkammer
djkammer's picture

Joined: 2002-10-10
Posts: 2
Posted: Thu, 2002-10-10 07:42

I was worried about idiots spamming my site with bogus comments, so I wanted to limit comments to logged in users. The following change to line 86 of util.php does the trick. (I realize that there is a way to hack around this if you know galley well enought to construct the add_comment url on you own. If you're really worried abot that, you could do something similar in the add_comment.php file)

Change line 86 of util.php from:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>"; </TD></TR></TABLE><!-- BBCode End -->

to:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>// HACK - prevent non-users from leaving comments
if( $gallery->user->isLoggedIn() )
{
echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";
}</TD></TR></TABLE><!-- BBCode End -->

MAKE SURE to back up the original file first!!!!

have fun,
Dave

 
linton

Joined: 2002-10-12
Posts: 42
Posted: Tue, 2002-10-15 22:56

I am going to try this hack with the new registering users hack. This is the comnbination that i have been looking for!

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Tue, 2002-10-15 23:34

I tried this hack

It doesnt work, it gives me error

maybe you give me the files and I can overwrite them?

Thanks!

 
linton

Joined: 2002-10-12
Posts: 42
Posted: Wed, 2002-10-16 00:10
Quote:
I tried this hack

It doesnt work, it gives me error

maybe you give me the files and I can overwrite them?

Thanks!

What files do you need?

What is givng you an error?

http://linton.tk/v1/gallery is the link to my gallery if you want a demo

 
josephp

Joined: 2002-10-03
Posts: 172
Posted: Wed, 2002-10-16 01:04

It just give me error

the gallery wont run at all and it says $ error something

 
linton

Joined: 2002-10-12
Posts: 42
Posted: Wed, 2002-10-16 01:21
 
linton

Joined: 2002-10-12
Posts: 42
Posted: Wed, 2002-10-16 01:22

Here is some code from util.php you can see what i have changed

$url = "add_comment.php?set_albumName={$gallery->album->fields[name]}&amp;index=$index";
$buf = "<span class=editlink>";
$buf .= '<a href="#" onClick="' . popup($url) . '">[add comment]</a>';
$buf .= "</span>";
//echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";
// HACK - prevent non-users from leaving comments
if( $gallery->user->isLoggedIn() )
{
echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";
}
//End Of Hack
}

 
djkammer
djkammer's picture

Joined: 2002-10-10
Posts: 2
Posted: Wed, 2002-10-16 23:10

sorry you're having troble with this, it's worked for me and several other folk i know. I should have said that this is based upon the source for 1.3.1 I haven't played with any of the earlier releases, so I don't know how different they are. If you can post your mod'ed code, along with the error you're getting or a url, maybe we can help.

 
AlienEx
AlienEx's picture

Joined: 2002-12-15
Posts: 8
Posted: Sun, 2002-12-29 00:19

This works wonderfully for my Postnuke site!

I have altered it slightly allowing a message to be shown under the photo/picture if not logged in to remind that person to register/login if they wish to leave comments. The code I am using is:

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> // HACK - prevent non-users from leaving comments
if( $gallery->user->isLoggedIn() )
{
echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";
}
else {
print "<b>TO LEAVE COMMENTS ON THIS PHOTO, YOU NEED TO LOGIN/REGISTER!</b>";
}
// END OF HACK
</TD></TR></TABLE><!-- BBCode End -->

 
itsnotlevel

Joined: 2005-09-28
Posts: 25
Posted: Sat, 2005-11-12 03:05

Just to let you guys know, this hack works perfectly on 1.5, WOOHOOO!