Jump to content

Recommended Posts

Hello everyone,

 

I’m working on a script to log user’s on one of our site’s to the mySQL database running on another one of our sites, we would like to keep track of domain, ip address, and time stamp.  What would be the best way to submit this information from one site to the other?  I was looking at a script today that would submit POST data from one site to another using sockets, I was not able to get this script working, so I’m asking on here for your ideas.

 

I know I could simply use a form and submit it via post or get but I do not want the user’s page to have to leave the current site and then back again, not sure if there is a simple way to do this or not.

 

PS. I don’t care if it’s POST, I’m not attached to the way we send data just as long as we can send the domain the user is on and their ip address.

 

Thanks for the reply PFMaBiSmAd,

 

It would depend on the site, in most cases it would not be on the same server.  I did some more Googling and found this tut: Sending POST form data with php CURL

 

I got it working using the following script:

session_start();

define('POSTURL', 'www.remotedomain.com/connection.php');
define('POSTVAR_DOMAIN', 'domain='.$_SERVER['HTTP_HOST']);
define('POSTVAR_IPADDRESS', '&ipaddress='.$_SERVER['REMOTE_ADDR']);

// INITIALIZE ALL VARS
$ch='';
$Rec_Data='';
$Temp_Output='';

if($_SERVER['REQUEST_METHOD']==='POST') {  // REQUIRE POST OR DIE

$ch = curl_init(POSTURL);
curl_setopt($ch, CURLOPT_POST      ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS    ,POSTVAR_DOMAIN.POSTVAR_IPADDRESS);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL
$Rec_Data = curl_exec($ch);

ob_start();
header("Content-Type: text/html");
$Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20");
$Temp_Output = ereg_replace (' +', ' ', trim($Temp_Output));
$Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output);
$Temp_Output = substr($Temp_Output,307,200);
echo $Temp_Output;
$Final_Out=ob_get_clean();
echo $Final_Out;
curl_close($ch);
} else die('Hacking attempt Logged!');

exit;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.