![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
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 ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Registered User
Join Date: Apr 2007
Posts: 9
|
I am afraid to use curl since some servers might not support it.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: May 2002
Location: Global traveler
Posts: 840
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
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();
__________________
Mechanical Bunny Media Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
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; ?> 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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
Registered User
Join Date: Apr 2007
Posts: 9
|
Quote:
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. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
|
wait a second, a girl who codes?!??
hot.
__________________
Mechanical Bunny Media Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
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.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: Jun 2005
Location: The Netherlands
Posts: 365
|
Quote:
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. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Registered User
Join Date: Apr 2007
Posts: 9
|
I don't want to give server1 access to the database.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Registered User
Join Date: Apr 2007
Posts: 9
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Confirmed User
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
|
<? exec("curl -d \"foo=bar&bar=foo\" \"urltootherfile\""); ?>
__________________
Mechanical Bunny Media Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
Registered User
Join Date: Apr 2007
Posts: 9
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 |
Registered User
Join Date: Apr 2007
Posts: 9
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,111
|
Quote:
But what do I know, I'm just a pert not an ex-pert. ![]()
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,111
|
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! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 |
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 |
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! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 |
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#22 | |
Registered User
Join Date: Apr 2007
Posts: 9
|
![]() Quote:
Thank you, Yours script works great and does exactly what I need. ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#23 |
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. ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#24 |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#25 |
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |