HACK - Self-Register / Registered Comments Only all in one!

linton

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

Compilation Gallery Hack!
Linton (i only did a little bit)
http://www.linton.tk/v1/gallery

Ok, this is a compilation of 2 other hacks that I DIDN'T WRITE! and a bit of my own work.
I am releasing this because if you are lazy like me and don't want to download a few different packs
then having it all in one place is really nice.

Step 1)
First you need to download the "allowing Users to Self-Register" hack by John_d and follow his instructions.
http://gallery.rennlist.com/user_login.zip

Step 2)
Second you need to view the "Only let logged in users leave comments" thread.

"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 enough to construct the add_comment url on you own.
If you're really worried about that, you could do something similar in the add_comment.php file)

Change line 86 of util.php from:
Code:
--------------------------------------------------------------------------------

echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";

--------------------------------------------------------------------------------

to:
Code:
--------------------------------------------------------------------------------

// HACK - prevent non-users from leaving comments
if( $gallery->user->isLoggedIn() )
{
echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";
}

--------------------------------------------------------------------------------

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

have fun,
Dave
"
That hack is from djkammer.

Step 3)
This is where my little part comes in to play, this is where you change the add_comments file so that the registered
users have to post under the name and e-mail address that they registered with.

Open up add_comment.php

Find Line #77 it should look like this <input type=hidden name="IPNumber" value="<?=$REMOTE_ADDR ?>">
right after it add the folowing line
<!---Hack so that the name posted in the comments is the same as the login name along with e-mail--->
<input type=hidden name="commenter_name" value="<?=$gallery->user->getFullname()?> ( <?=$gallery->user->getEmail()?> )" ></>

Next
Then on line 81 which looks like <input name="commenter_name" value="<?=$commenter_name?>" size=30>

Now replace it with this
<?=$gallery->user->getFullname()?>

And that is it. If you have any problems leave a msg in this thread or e-mail me at

 
macsamurai

Joined: 2002-12-01
Posts: 16
Posted: Sun, 2002-12-08 19:59

This simple self-register hack works great! It's exactly what I was loking for! Thanks for posting it!

Now if only there was an easy, stadalone "last x pictures uploaded" or "view new pictures since last login". Everything I have found that's close, revolves around the last ALBUM, which isn't really relevant in my case, since I create master albums as categories and users upload indiv photos into those existing albums - or it requires *nuke or something similar, which i have no intention of switching to.

At least I don't have to manually register everyone that emails me now though. Great time saver. I set permissions for all albums to have "logged in" users able to upload photos and it's all done without my having to worry about a thing.

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Tue, 2002-12-10 21:04

great job on putting that together linton. but i got some questions for you. how did you get that Please register before posting to show up in the inline.photo.footer when the user is not logged in and then how did you get it to not show up when the do log in?. also, i was wondering if there was a way to pre set permissions for the new users that self register. because when some one registers for your site they have access to add new albums and everything. i want to restrict access to only posting comments. know a way?

 
linton

Joined: 2002-10-12
Posts: 42
Posted: Tue, 2002-12-10 21:28
 
linton

Joined: 2002-10-12
Posts: 42
Posted: Tue, 2002-12-10 21:29

OK, so this posting thing is not working right .. here is what you got to do.

Find line 64 in utils.php ...it is the start to the viewComment functions.

Right after the lines

$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>";

add this

$url1 = "user.php";
$buf1 = "<span class=editlink>";
$buf1 .= 'Please <a href="#" onClick="' . popup($url1) . '">[Register]</a> to add comments';
$buf1 .= "</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>";
}
else{
echo "<tr align=center><td colspan=3>$buf1<br><br></td></tr>";
}
//End Of Hack

thanks should be all you need, about the change in premissions i am not sure .. but i will look into it.

thanks
linton

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Tue, 2002-12-10 21:45

ok i did that and it seemed to work but when i log in....i now have 2 add comment lines. not a super big deal but would you know how to get rid of one?

 
linton

Joined: 2002-10-12
Posts: 42
Posted: Wed, 2002-12-11 00:33

I do .... if you look in the code of the last post i have commented out the original link which is

//echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";

that is all you have to do, you will now only get one add comment link.

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Wed, 2002-12-11 02:04

i dont get it. what do i have to do?

 
dtdgoomba

Joined: 2002-11-04
Posts: 185
Posted: Wed, 2002-12-11 02:12

In case you're not familiar with PHP coding, putting

//

in front of a line of code, keeps it from being run, so in that case
//echo etc will not happen.

if you knew this, then maybe you're asking something different. does this help?

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Wed, 2002-12-11 02:16

no i understand that... i just dont understand which line i have to comment out. did you edit the post to make it right? id ont see what to change

edit: ok i got it. heres what i did. right after the hack code you supplied theres
// HACK - prevent non-users from leaving comments
if( $gallery->user->isLoggedIn() )
{
//echo "<tr align=center><td colspan=3>$buf<br><br></td></tr>";

i just added that // before the echo and when i log in, the add comment feature is there only once. its good. thanks alot!

 
dtdgoomba

Joined: 2002-11-04
Posts: 185
Posted: Wed, 2002-12-11 04:09

ok :smile: sorry, i thought you might know what a // was

Isn't the line linton is referring to just above //HACK?

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Sat, 2002-12-14 22:40

hey linton or whoever... when users try to leave comments now.. no user name appears when they submit it. it only shows the email addy. any ideas on how to fix it?