comment table incl ip/host (code inside) comment table incl ip/host (code inside)
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

comment table incl ip/host (code inside)

Started by boii, October 04, 2003, 06:28:55 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

boii

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

boii

okay so does this look right before i implement it:

throw this in db_input.php:

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


and then find this:

        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:

        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:

        } 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:

        } 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).

Tarique Sani

Sorry to be rain on your parade - this has already been done
SANIsoft PHP applications for E Biz

boii

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

boii

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

Tarique Sani

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 :)
SANIsoft PHP applications for E Biz

boii

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

Joachim Müller

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

boii

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


$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:

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

to:

<!-- <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