Multiple Headers
Moderator: General Moderators
-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm
Multiple Headers
hello to all..
I`m currenly writing a migration scripts for about 6000 records. I`ve been givin instruction to send the record to a URL whici looks like this:
http://256.256.256:256/migrate.cfm?cmd= ... ord&aff=ID...
from what I understand is that this will direct the function migratecust in their migrate.cfm file to pick up all the arguments and insert them in their database.
However my problem here is how i send or automate this process. i can build the URLs for each customer dynamically but I cant send all the URLs or automate it so that it execute one after the other.
I have tried using a for loop and inserting session_start() and session_destroy() but its only the last record that is being migrated.
Any help on this will be very very much apreciated.
Thanks a million in advance..
I`m currenly writing a migration scripts for about 6000 records. I`ve been givin instruction to send the record to a URL whici looks like this:
http://256.256.256:256/migrate.cfm?cmd= ... ord&aff=ID...
from what I understand is that this will direct the function migratecust in their migrate.cfm file to pick up all the arguments and insert them in their database.
However my problem here is how i send or automate this process. i can build the URLs for each customer dynamically but I cant send all the URLs or automate it so that it execute one after the other.
I have tried using a for loop and inserting session_start() and session_destroy() but its only the last record that is being migrated.
Any help on this will be very very much apreciated.
Thanks a million in advance..
Get all the required content into an array. Use a foreach() loop. Use get_file_contents() with the URL, and then you can parse the response, if any (eg. if there is a "Inserted Successfully!" message you could identify that with this method).
Page loading might be an issue so you might want to limit the array size by limiting the array insertion process.
eg. instead of calling 6,000 rows from the db into the array use something like LIMIT 0, 300 then LIMIT 301, 600, and etc.
Page loading might be an issue so you might want to limit the array size by limiting the array insertion process.
eg. instead of calling 6,000 rows from the db into the array use something like LIMIT 0, 300 then LIMIT 301, 600, and etc.
Last edited by m3mn0n on Sun Nov 06, 2005 2:12 pm, edited 1 time in total.
Indeed but when dealing with strictly server-server communication (like I believe he is talking about), the security issue of viewing passwords in the URL of a browser is non-existant. And I do not believe he has control over the destination script, he is bound to the syntax provided.foobar wrote:NEVER PASS PASSWORDS AND DATABASE COMMANDS VIA A GET REQUEST.
-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm
yes sami, its indeed communication between 2 servers. Actually we are changing one of our poker clients and we need to migrate the existing customers to the new poker platform. Currently we are only migrating to their test platform but later i believe they will ask to send it over SSL.
I will try to use the get_file_contents to see if it works. what if no response come from the url? does it still go to the next url in the loop?
Thanks a lot for your supoort sami. I will try that one and keep you posted on this.
thanks
I will try to use the get_file_contents to see if it works. what if no response come from the url? does it still go to the next url in the loop?
Thanks a lot for your supoort sami. I will try that one and keep you posted on this.
thanks
-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm
-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm
I`ve tried the get_header() function instaed and it seems to be working but now the problem is that my script halt execution after 30 seconds. I remember trying to run a scirpt through command line so that i dnt get the timeout error.
However when trying to run the file from command line it seems that its not doing anything.
The code is as follows:
and the target.php is as follows:
Any suggestion?
Thanks
However when trying to run the file from command line it seems that its not doing anything.
The code is as follows:
Code: Select all
for ($i=0;$i<100;$i++)
{
//echo $i;
$x=get_headers('http://10.1.1.228/migrate/target.php?i='.$i);
}and the target.php is as follows:
Code: Select all
echo $i;
$connection = pg_connect("dbname=B_DEV user=postgres host=10.1.1.46");
if (!$connection) {
print("Connection Failed.");
exit;
}
$myresult = pg_exec($connection, "insert into migration_test.migtab(pin) values('$i')");
if (! $myresult) {
return "failed";
}
else {
return "success";
}Any suggestion?
Thanks
My mistake.
*gets some more caffeine*
It'll return false if the connection to the file/server is not established so you can process an error message from that.
eg.
Code: Select all
<?php
$count = 1;
foreach ($dataarray as $key => $val)
{
$html = file_get_contents ($the_url_with_the_vars); // connection
if ($html == FALSE)
{
// echo that the processing of $count failed
} else {
// parse html responce and retrieve msg if any
}
$count++;
}
?>-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm
Put this at the top of your script! Next line after * <?php or <? * !
If you doing this from a browser, once you start / call the script, you can just close the browser, it will run until it is done doing what you asked it to do in the script!
yj
Code: Select all
ignore_user_abort ( 'true' );
set_time_limit ( 0 );yj
-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm
-
cyberstryke
- Forum Newbie
- Posts: 15
- Joined: Sun Nov 06, 2005 1:34 pm