Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-18-2007, 02:09 PM   #1
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
PHP assistance needed - experts only please!

Hi,
My name is Betty and I need some help.

I want to send a data string from a php file on 1 server to another php file on another server.

example:

Server 1 / file1.php -> Server 2 / file2.php
Server 2 / file2.php -> Server 1 / file1.php

It's actually posting data to another file on another server and getting the result.

Thank you,
Betty
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 02:10 PM   #2
naitirps
Confirmed User
 
Join Date: May 2004
Location: ...
Posts: 761
use curl within php to post to the other server/script
__________________
Programmer
ICQ 44035273 | AIM spritwork | Email spritian at spritian dot com
naitirps is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 02:14 PM   #3
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
I am afraid to use curl since some servers might not support it.
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 02:15 PM   #4
Yahook
Confirmed User
 
Yahook's Avatar
 
Industry Role:
Join Date: May 2002
Location: Global traveler
Posts: 840
http://sourceforge.net/projects/nusoap/
Yahook is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 02:21 PM   #5
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
most servers have curl installed. If you dont wanna use the php extensions, use curl from cli using exec();
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 02:43 PM   #6
adultseo
Confirmed User
 
Join Date: Jun 2005
Location: The Netherlands
Posts: 365
Hi!

The most easy way is this:

Server 1:
Code:
<?php

$data = array(array(1,3,4,5),1,2,3,4,array(array(10,11,12),'test'));
$output = var_export($data,true);

print $output;

?>
Server 2:
Code:
<?php

$data_text = file_get_contents('url/to/server_1.php');
eval('$data = '.$data_text.';');

print_r($data);

?>
__________________
The key to get ranked one in Google is to provide the best.
adultseo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 02:58 PM   #7
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
"Experts only" for simple questions, please!



I'm not making fun of you, it just made me chuckle.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:19 PM   #8
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
Quote:
Originally Posted by adultseo View Post
Hi!

The most easy way is this:

Server 1:
Code:
<?php

$data = array(array(1,3,4,5),1,2,3,4,array(array(10,11,12),'test'));
$output = var_export($data,true);

print $output;

?>
Server 2:
Code:
<?php

$data_text = file_get_contents('url/to/server_1.php');
eval('$data = '.$data_text.';');

print_r($data);

?>

Thank you, but I don't understand.
I need to send data to the other server and accourding to this data perform an action. I didn't mean to just read the data as is on the other server.
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:20 PM   #9
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
wait a second, a girl who codes?!??
hot.
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:29 PM   #10
Zoose
Confirmed User
 
Join Date: Aug 2006
Posts: 268
Is this data from a database? If so just give the server that needs the data proper access privileges in MySQL and vice versa. Depending on the data you might even be able to do it with fopen and query strings. It's hard to give you advice without knowing the exact situation.
Zoose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:30 PM   #11
adultseo
Confirmed User
 
Join Date: Jun 2005
Location: The Netherlands
Posts: 365
Quote:
Originally Posted by betty1980 View Post
Thank you, but I don't understand.
I need to send data to the other server and accourding to this data perform an action. I didn't mean to just read the data as is on the other server.
what kind of data are you trying to submit?

You can use a regulare header post configuration, Curl is nothing more then a automated system for regular header commands. It can be done manually aswell.
__________________
The key to get ranked one in Google is to provide the best.
adultseo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:31 PM   #12
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
I don't want to give server1 access to the database.
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:32 PM   #13
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
Quote:
Originally Posted by adultseo View Post
what kind of data are you trying to submit?

You can use a regulare header post configuration, Curl is nothing more then a automated system for regular header commands. It can be done manually aswell.
The data is a text string.
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:38 PM   #14
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
<? exec("curl -d \"foo=bar&bar=foo\" \"urltootherfile\""); ?>
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:52 PM   #15
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
Quote:
Originally Posted by adultseo View Post
what kind of data are you trying to submit?

You can use a regulare header post configuration, Curl is nothing more then a automated system for regular header commands. It can be done manually aswell.
Can you send me an example?
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 03:56 PM   #16
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
Quote:
Originally Posted by k0nr4d View Post
<? exec("curl -d \"foo=bar&bar=foo\" \"urltootherfile\""); ?>
2 questions:

1. Do you know if there is a limit to the length of the string. foo=$report, what is the maximum length of $report ?
2. How do I get the returned value?
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 05:14 PM   #17
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,111
Quote:
Originally Posted by edgeprod View Post
"Experts only" for simple questions, please!



I'm not making fun of you, it just made me chuckle.
Yeah, that was how I looked at it too. I thinks she is making it harder than it actually is.

But what do I know, I'm just a pert not an ex-pert.

__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 05:17 PM   #18
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,111
Quote:
Originally Posted by betty1980 View Post
Thank you, but I don't understand.
I need to send data to the other server and accourding to this data perform an action. I didn't mean to just read the data as is on the other server.
He was performing an action. Printing it. You could substitute any particular action you wanted to perform on the data where he had the print statement.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 05:51 PM   #19
adultseo
Confirmed User
 
Join Date: Jun 2005
Location: The Netherlands
Posts: 365
Code:
function HTTPS_Post($URL, $dat, $referrer="")
{
// parsing the given URL
$URL_Info=parse_url($URL);

// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=$_SERVER["SCRIPT_URI"];

// making string from $data
foreach($dat as $key=>$value) $values[]="$key=".urlencode($value);
$data_string=implode("&",$values);

// Find out which port is needed - if not given use standard (=443)
if(!isset($URL_Info["port"])) $URL_Info["port"] = 80;

// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n";

$result = '';
if ($fp = fsockopen("ssl://" . $URL_Info["host"], $URL_Info["port"],
$errno, $errstr, 2.0))
{
fputs($fp, $request);
$started = time;
while((!feof($fp)) and ((time - $started) < 5))
{
$result .= @fgets($fp, 128);
}
fclose($fp);
}
return $result;
}
__________________
The key to get ranked one in Google is to provide the best.
adultseo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 05:52 PM   #20
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,111
Ok, several people have asked you more more info and you aren't really offering anything up, so I will offer up what I think is the simplest solution, however, it would help to know what you are actually trying to do.

This is a 2 script solution. script1 is on server1, script2 is on server2.

Script1 is kicked off somehow (depending on what you are doing) either a call from a browser, a post action in a form, a cron job, whatever.

script1 collects or retrieves data (whatever your initial data source is)
script1 writes the data to a file on server1 (or could write it via ftp it to server2)
script1 then does an fopen() to script2 on server2

script2 opens the file created by script1 whether via fopen() to the url for the file on server1 or an fopen() to the file where it was written on server2
script2 performs whatever steps are required to be performed on the data (writes it to a database, performs verification, jerks off to it, whatever)
script2 returns a done message (which could be the results of the steps performed in script2).

done.

There are, as people have said, many different ways to skin this particular cat. It seems to me though, from watching this conversation, that you need to draw out your step by step of what you are actually trying to do.

just my
__________________
All cookies cleared!

Last edited by sarettah; 04-18-2007 at 05:54 PM..
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 05:56 PM   #21
adultseo
Confirmed User
 
Join Date: Jun 2005
Location: The Netherlands
Posts: 365
Code:
$options = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>
      "Accept-language: en\r\n".
      "Content-type: application/x-www-form-urlencoded\r\n",
    'content'=>http_build_query(array('foo'=>'bar'))
));

$context = stream_context_create($options);

fopen('http://www.example.com/',false,$context);
__________________
The key to get ranked one in Google is to provide the best.
adultseo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-18-2007, 11:59 PM   #22
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9

Quote:
Originally Posted by adultseo View Post
Code:
function HTTPS_Post($URL, $dat, $referrer="")
{
// parsing the given URL
$URL_Info=parse_url($URL);

// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=$_SERVER["SCRIPT_URI"];

// making string from $data
foreach($dat as $key=>$value) $values[]="$key=".urlencode($value);
$data_string=implode("&",$values);

// Find out which port is needed - if not given use standard (=443)
if(!isset($URL_Info["port"])) $URL_Info["port"] = 80;

// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n";

$result = '';
if ($fp = fsockopen("ssl://" . $URL_Info["host"], $URL_Info["port"],
$errno, $errstr, 2.0))
{
fputs($fp, $request);
$started = time;
while((!feof($fp)) and ((time - $started) < 5))
{
$result .= @fgets($fp, 128);
}
fclose($fp);
}
return $result;
}

Thank you,
Yours script works great and does exactly what I need.
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-19-2007, 12:07 AM   #23
betty1980
Registered User
 
Join Date: Apr 2007
Posts: 9
I would like to thank you all for your help. I appreciate it.
For all of you that didn't understand me for asking experts help, I didn't mean to insult you, but before I have tried to post this question on another form and got answers that didn't help much, so I though I would need an expert for that.
Thanks again,

Love,
Betty.
betty1980 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-19-2007, 04:10 PM   #24
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
Quote:
Originally Posted by betty1980 View Post
Thank you,
Yours script works great and does exactly what I need.
It's not his script. It's from a script site.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-19-2007, 10:45 PM   #25
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by betty1980 View Post
Thank you,
Yours script works great and does exactly what I need.
No idea what you're using it for, but you may well want to think about sanitising the post vars on server 2, or passing a key in the post from server 1...
__________________

For coding work - hit me up on andy // borkedcoder // com
(consider figuring out the email as test #1)



All models are wrong, but some are useful. George E.P. Box. p202
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.