forum.coppermine-gallery.net

No Support => Feature requests => Topic started by: boii on October 04, 2003, 06:28:55 am

Title: comment table incl ip/host (code inside)
Post by: boii on October 04, 2003, 06:28:55 am
i mean this is a severely easy addition, id do it myself if i wasnt at a cybercafe, just adding 2 columns to the comments table and in the add comment code having it insert the ip & host into each field.

it'd be snazzy if you were logged in as admin to to view it on the page also.

can show me where the comment insert code is so i can hack this together quickly? (and for anyone who knows oppermien code, will the addition of two tabel columns or what ive described break anything?)

cheers.
ken
Title: comment table incl ip/host (code inside)
Post by: boii on October 04, 2003, 06:44:35 am
okay so does this look right before i implement it:

throw this in db_input.php:
Code: [Select]

//
// Comment
//
$user_ip = getenv ("REMOTE_ADDR");
$user_host = getenv ("REMOTE_HOST");


and then find this:
Code: [Select]

        if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
                $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0')");


change to:
Code: [Select]

        if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
                $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, user_ip, user_host) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$user_ip','$user_host')");


and find:
Code: [Select]

        } else { // Registered users, we can use Location to redirect
                $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id) VALUES ('$pid', '".addslashes(USER_NAME)."', '$msg_body', NOW(), '', '".USER_ID."')");


change to:
Code: [Select]

        } else { // Registered users, we can use Location to redirect
                $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, user_ip, user_host) VALUES ('$pid', '".addslashes(USER_NAME)."', '$msg_body', NOW(), '', '".USER_ID."','$user_ip', '$user_host')");


(also make sure you added the two columns in your comments table called 'user_ip' and 'user_host')

i havent implemented it yet, waiting for someone to look at it and tell me if itll break. i dont have a test versionof coppermine up.

cheers.
ken

edit: obviously this wont display it within coppermine, youll have to look at it in the actual db. when i have more time to sit down (see next year, im traveling!) and put it together is when ill add it to the display pages (unless someone does it first).
Title: comment table incl ip/host (code inside)
Post by: Tarique Sani on October 04, 2003, 06:53:34 am
Sorry to be rain on your parade - this has already been done
Title: comment table incl ip/host (code inside)
Post by: boii on October 04, 2003, 07:41:48 am
hey, all the better. im happy it was done. now where can i get my hands on the code? :D

done or not, its not currently in my coppermine version (and im glad i then assume itll be in 1.2) but how can i go about mod'ing the current one to have ip/hosts included (does my hack look right?..id rather use the other if its proven).

cheers.
ken
Title: comment table incl ip/host (code inside)
Post by: boii on October 04, 2003, 08:37:14 am
anyhow.
for anyone who also has no idea where this code tarique refers to is..

i just tried mine, it works.

feel free to use it.

cheers.
ken
Title: comment table incl ip/host (code inside)
Post by: Tarique Sani on October 04, 2003, 09:10:41 am
Quote from: "boii"
for anyone who also has no idea where this code tarique refers to is..


Let me tell you that it will be in the next version :)
Title: comment table incl ip/host (code inside)
Post by: boii on October 04, 2003, 09:59:29 am
Quote from: "tarique"
Quote from: "boii"
for anyone who also has no idea where this code tarique refers to is..


Let me tell you that it will be in the next version :)


rock on.
here's a quick question that maybe you can answer..

when one will upgrade from 1.1.0 to 1.2.x, those of who have made mods (ie: the one i posted above, and god knows what else here and there), will we lose or screw somethign up by havign a diff database structure or code in certain files?

i assume the only answer can be yes ;)

cheers.
ken
Title: comment table incl ip/host (code inside)
Post by: Joachim Müller on October 04, 2003, 10:43:41 am
yup,

as you'll have to replace nearly all files, all mods will be lost. I haven't heard of a software that is capable of preserving the mods when there's an update (except they're all done in separate files).

GauGau
Title: comment table incl ip/host (code inside)
Post by: boii on October 14, 2003, 06:09:00 am
i know. i know.
this is already in the next version.

but for anyone who so happened to use the code above:

i edited two lines in: reviewcom.php to display the hostname next to msg author/date

Code: [Select]

$result = db_query("SELECT msg_id, msg_author, msg_body, user_host, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, {$CONFIG['TABLE_COMMENTS']}.pid as pid, aid, filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']} WHERE {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid ORDER BY msg_id DESC LIMIT $start, $count");

^ just added ' user_host,' in the db_query.

changed:
Code: [Select]

<td><b>{$row['msg_author']}</b> - {$msg_date}</td>

to:
Code: [Select]

<!-- <td><b>{$row['msg_author']}</b> - {$msg_date}</td> -->
<td><b>{$row['msg_author']}</b> - {$msg_date} : {$row['user_host']}</td>


simple enough. and now you can see the hostname in the review of comments without logging into the db.

cheers.
ken