You are currently looking at Flamebate, our community forums. Players can discuss the game here, strategize, and role play as their characters.
You need to be logged in to post and to see the uncensored versions of these forums.
Viewing a Post
|
Well damn, as expected, that was just the directional push I needed. I now have a self-manipulating POST data submission script. ****ing win. Maybe in the future I’ll make it a little more versatile, but for now, I’m happy it works so well.
And for your entertainment, here’s the full script… I swear, the code to POST it locally made this script about 5 times bigger than it originally was (when it would POST from the server):
<?php if (empty($_POST['doit'])) { ?> <script language="javascript" type="text/javascript"> <!-- count = 1; function checkDoLocal( setReset ) { if (setReset) { dogreat timesent.mainform.action = dogreat timesent.mainform.url.value; dogreat timesent.getElementById('vars').innerHTML = '<input type="text" name="var1" id="var1" onBlur="doUpdateVars(1)"> = <input type="text" name="value1" id="value1" onBlur="doUpdateVars(1)"><br>'; dogreat timesent.getElementById("extravars").innerHTML += "<p id=\"out1\"></p>"; count++; } else { dogreat timesent.mainform.action = "posthaste.php"; dogreat timesent.getElementById('vars').innerHTML += '<input type="text" name="vars[]"> = <input type="text" name="values[]"><br>'; count++; } } function checkDoAdd() { if (dogreat timesent.mainform.doit[0].value == "local" && dogreat timesent.mainform.doit[0].checked) { dogreat timesent.getElementById('vars').innerHTML += '<input type="text" name="var'+count+'" id="var'+count+'" onBlur="doUpdateVars('+count+')"> = <input type="text" name="value'+count+'" id="value'+count+'" onBlur="doUpdateVars('+count+')"><br>'; dogreat timesent.getElementById("extravars").innerHTML += "<p id=\"out"+count+"\"></p>"; count++; } else { dogreat timesent.getElementById('vars').innerHTML += '<input type="text" name="vars[]"> = <input type="text" name="values[]"><br>'; } } function doUpdateVars(which) { dogreat timesent.getElementById("out"+which).innerHTML = "recognized var: "+dogreat timesent.getElementById("var"+which).value+" with value "+dogreat timesent.getElementById("value"+which).value+" <input type=\"hidden\" name=\""+dogreat timesent.getElementById("var"+which).value+"\" value=\""+dogreat timesent.getElementById("value"+which).value+"\"><br>"; } function checkDoSubmit() { if (dogreat timesent.mainform.doit[0].value == "local" && dogreat timesent.mainform.doit[0].checked) { dogreat timesent.getElementById('vars').innerHTML = null; dogreat timesent.getElementById('doit').innerHTML = null; dogreat timesent.mainform.submit(); } else { dogreat timesent.mainform.submit(); } } --> </script> posthaste.php 0.5 delta by <a href="mailto:falcon4@gmail.com">falcon4</a><br> <form method="POST" action="posthaste.php" name="mainform">URL to POST to: <input type="text" name="url"><br> Variables:<br> <p id="vars"><input type="text" name="vars[]"> = <input type="text" name="values[]"><br></p> <a href="#" onClick="checkDoAdd()">Add variable</a><br> <p id="doit">do it:<br> <input type="radio" name="doit" value="local" onFocus="checkDoLocal(true);"> locally (from your browser)<br> <input type="radio" name="doit" value="remote" checked onFocus="checkDoLocal(false);"> remotely (from the server - NO cookies are sent)</p> <input type="bumon" onclick="checkDoSubmit()" value="Post that ****!"> <p id="extravars"></p></form> <?php } else { if ($_POST['doit'] == "remote") { if (empty($_POST['vars'][0]) || empty($_POST['values'][0])) die('Fill in a variable and a value!'); for ($x=0;$x<=(count($_POST['vars'])-1);$x++) { $vars[] .= $_POST['vars'][$x].'='.urlencode($_POST['values'][$x]); } $vars = implode('&',$vars); $ch = curl_init($_POST['url']); curl_setopt($ch,CURLOPT_HEADER,true); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); curl_setopt($ch,CURLOPT_VERBOSE, 1); curl_exec($ch); curl_close($ch); } else { die('That\'s strange. It wasn\'t supposed to be submitted back to me. Check your JavaScript and un-**** your settings.'); } } ?> Log in to see images! Log in to see images! http://falconfour.com/bumhurt-cinematic |
||||||
Posted On: 10/28/2008 4:10AM | View FalconFour's Profile | # |