 |
Apache2Triad Help, Support and Development The apache2triad help , support and development forums
|
| View previous topic :: View next topic |
| Author |
Message |
Joshua Meadows (DemoRic)
Joined: 29 Dec 2004
Posts: 785
Location: S.E. Kansas
|
| Posted: Fri Nov 17, 2006 11:09 pm Post subject: [PHP] resending post data to another page |
|
|
I am having difficulty trying to do this. I have some swf files that try to incorrectly post to a php file at the root of my server instead of a diiferent location.
I have tried using mod_rewrite, but found this removes post data.
I have getting the post data using php's input to put in a form to resubmit to the proper php page, but the data makes the post data too long. I have tried passing $_POST, but that doesn't work.
I want the data flow like this.
swf -> post -> wrongphp -> post -> rightphp
Any suggestions?
Code:
// Fugly stuff to show people because some autoarcade games don't work
$referer = $_SERVER['HTTP_REFERER'];
ECHO "<META HTTP-EQUIV=\"Refresh\"
CONTENT=\"15; URL=$referer\">What are you doing here? You shouldn't be here! <i>(Well maybe this is a bug we need to fix.)</i><br /> Redirecting you back to where you came from in <b><i>15</i></b> seconds. Have fun playing those flash games. We HOPE to fix this soon<br />\n";
ECHO "<b>Redirect you to $referer </b><br /><hr />";
$rawPostData = file_get_contents('php://input'); // done!
if ($_POST) {
$postdata = file_get_contents('php://input');
$uglybugger = '/(?<=&)([^&=]+)(?:=([^&]*))/';
$matches = array();
preg_match_all($uglybugger, $postdata, $matches);
$_POST = array();
$match_count = count($matches[0]);
for ($i = 0; $i < $match_count; $i++) {
if (!isset($_POST[$matches[1][$i]])) {
$_POST[$matches[1][$i]] = array();
}
$_POST[$matches[1][$i]][] = $matches[2][$i];
}
$match_count = count($_POST);
for ($i = 0; $i < $match_count; $i++) {
if (count($_POST[$i]) == 1) {
$_POST[$i] = $_POST[$i][0];
}
}
}
//ECHO "<br />$rawPostData<br />";
//ECHO " <button type=\"button\" class=\"button\" onClick=\"window.location='/e107_plugins/autogallery/proarcade.php?".$postdata."['\">Try to Manually Submit Score</button></form></div>";
//ECHO "<button type=\"submit\" class=\"button\" action=\"/e107_plugins/autogallery/proarcade.php\" value=\"$postdata\"onClick=\"window.location='/e107_plugins/autogallery/proarcade.php\">".FMP_PLAY."</button>";
ECHO "Post: $_POST <br />";
foreach ($_POST as $tempString ) {
ECHO $tempString."<br />\n";
$completePost = $completePost+$tempString;
}
ECHO "GET:$_GET <br />";
foreach ($_GET as $tempString ) {
ECHO $tempString."<br />\n";
}
ECHO "Query: $getQuery<br />";
// End Fugly stuff to show people because some autoarcade games don't work
require_once(dirname(__FILE__)."/e107_plugins/autogallery/def.php");
if (!isset($_POST['score'])) exit;
$points = $_POST['score'];
AutoGal_AddScoreViaReferer($points); |
|
| Back to top |
|
cigraphics
Joined: 21 Aug 2005
Posts: 152
Location: Romania, Pitesti
|
| Posted: Tue Nov 21, 2006 11:39 am Post subject: |
|
|
try to put in the wrongphp another form like this
Code:
<form action="rightphp" method="post">
<input type="hidden" name="name" value="<?=$_POST['what'];?>"/>
<input type="hidden" name="name2" value="<?=$_POST['what2'];?>"/>
<input type="submit" name="go" value="Submit" />
</form>
or with $_GET[]
then modify the method and you must change $_POST[] to $_GET[] |
|
| Back to top |
|
Joshua Meadows (DemoRic)
Joined: 29 Dec 2004
Posts: 785
Location: S.E. Kansas
|
| Posted: Wed Nov 22, 2006 12:57 am Post subject: |
|
|
Hey thanks Cigraphics. I also had coded 2 solutions since I posted here. (the first was essentially what you suggested)
The first creates a submit button that re-posts the $_post contents.
Quote: $referer = $_SERVER['HTTP_REFERER'];
ECHO "<FORM action=\"/pathto/correct.php\" method=\"post\">";
foreach ($_POST as $key => $value) {
ECHO "<input type=\"hidden\" name=\"$key\" value=\"$value\">";
//$$key = addslashes(trim($value));
}
ECHO "<input type=\"submit\" value=\"Submit Score\"></form>";
The other method essentially lies to the browser to tell it the file has temporarily moved.
Quote: header("HTTP/1.0 307 Temporary Redirect");//Temporary Redirect Page.
$uri="/pathto/correct.php";
header( "Location: http" .
( isset($_SERVER['REQUEST_URI']) ? $uri .
( $_SERVER['QUERY_STRING'] ? "?" . $_SERVER
['QUERY_STRING'] : "" ) : "" ) );
The thing I found out after doing all of it was that it is a sessions issue, which I still haven't resolved. (Oh, well I've got some new php scripts for my coding toolbox.)
Anyways, Thanks for the reply. :) |
|
| Back to top |
|
| |
|