This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!
Poll: Did this help? - You do not have permission to vote in this poll.
Yes
0%
0
0%
I have no idea what you are saying!
0%
0
0%
* You voted for this item. Show Results


Use Commentics script within a existing Member logged in web site - change ip_address
#1

Insert your clients unique id in the ip_address field, instead of a server ip address within a secure logged in website you already created.

Also cross reference to thread
http://www.commentics.org/forum/showthre...83#pid3583
(Problem where everybody on the network share the same ip_address)

On your first php landing page after member has logged in.

Create the server variable MM_Username to create a recordset (I called mine rslogindetails) attaching to all the table details of your logged in member.

My table with all members details is called client. My members username (MM_Username) is attach to the field 'clientemail' within the client table.
So I basically just join the two in the record set, where my logged in username is also my members email address (clientemail)

PHP Code:
<?php $colname_rslogindetails = "-1";
if (isset(
$_SESSION['MM_Username'])) {
$colname_rslogindetails = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_yourdatabasename, $yourdatabasename);
$query_rslogindetails = sprintf("SELECT * FROM client WHERE clientemail = %s", GetSQLValueString($colname_rslogindetails, "text"));
$rslogindetails = mysql_query($query_rslogindetails, $yourdatabasename) or die(mysql_error());
$row_rslogindetails = mysql_fetch_assoc($rslogindetails);
$totalRows_rslogindetails = mysql_num_rows($rslogindetails);
?>

After creating above recordset, my whole website from here basically works on the client unique id 'clientid' field (a Auto Incriment number created when signing up)

I want THIS NUMBER to become my unique ip_address in commentics, comments table.

So still within my landing page I am going to create a server variable, and attach this to the clientid (within my created recordset rslogindetails).
I called this variable 'clientnumber' and = it to the field containing the unique id number in my table called 'clientid'

PHP Code:
<?php 
// this starts the session
if (!isset($_SESSION)) {
session_start();
}
// this sets variables in the session
$_SESSION['clientnumber']=$row_rslogindetails['clientid'];
?>

Now for each member signing in, I have their unique id captured in the session variable called 'clientnumber'. If I want to display it anywhere
PHP Code:
<?php 
$_SESSION
['clientnumber'];
John is '4' and Mike is '6' etc.

Now the easy part to post this number as you commentics ip_address
Open the php page at includes/functions/page.php
and find the following code in the script
PHP Code:
<?php 
function cmtx_get_ip_address() { //get IP address

if (isset($_SERVER)) {
if (isset(
$_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if (isset(
$_SERVER['HTTP_CLIENT_IP'])) {
$ip_address = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip_address = $_SERVER['REMOTE_ADDR'];
}
} else {
if (
getenv('HTTP_X_FORWARDED_FOR')) {
$ip_address = getenv('HTTP_X_FORWARDED_FOR');
} else if (
getenv('HTTP_CLIENT_IP')) {
$ip_address = getenv('HTTP_CLIENT_IP');
} else {
$ip_address = getenv('REMOTE_ADDR');
}
}

$ip_address = cmtx_sanitize($ip_address, true, true, true);

return
$ip_address; //return IP address

} //end of get-ip-address function

and replace with
PHP Code:
<?php 
function cmtx_get_ip_address() { //get IP address

$ip_address = $_SESSION['clientnumber'];
$ip_address = cmtx_sanitize($ip_address, true, true, true);

return
$ip_address; //return IP address

} //end of get-ip-address function

Viola!
Instead of posting something like 145.27.108 it just posts my members unique id.
I'ts great because I also save my members photos with their id 1.jpg, 4.jpg etc, and can now also attach it to the gravatar script. Not only this but using this clientnumber I can quickly create links to all my members posts etc. - all custom to your already created database. It all cross reference my existing build database.

Thanks to commentics for a great script!
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
21-Aug-2023, 08:03 PM
Last Post by Steven
16-Oct-2017, 08:11 AM
Last Post by gongong
18-Feb-2017, 04:16 AM
Last Post by Steven
07-Jul-2015, 05:57 PM
Last Post by Steven
29-May-2015, 08:51 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)