budd Posted June 18, 2009 Share Posted June 18, 2009 ok so i found a way to encrypt part of a url to stop people editing it /** * Encrypt/decrypt url * Encrypts and decrypts url * Usage example: - 'index.php?A='.encrypt_url("somedata") * - decrypt_url($GET['A']) */ function encrypt_url($string) { $key = "123abc"; //preset key to use on all encrypt and decrypts. $result = ''; for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)+ord($keychar)); $result.=$char; } return urlencode(base64_encode($result)); } $publish = array('method'=> 'feedStory', 'content' => array( 'feed' => $feed, 'next' => $appCanvasUrl.'inventory.php?aid='.$_POST[arms_ID].'&prc='.encrypt_url($_POST[arms_Price]).'&amt='.encrypt_url($_POST[arms_amount]).'&action=buyarms')); and then in a file that a include file of page the code above it from /** * Encrypt/decrypt url * Encrypts and decrypts url * Usage example: - 'index.php?A='.encrypt_url("somedata") * - decrypt_url($GET['A']) */ function encrypt_url($string) { $key = "123abc"; //preset key to use on all encrypt and decrypts. $result = ''; for($i=0; $i<strlen($string); $i++) { $char = substr($string, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)+ord($keychar)); $result.=$char; } return urlencode(base64_encode($result)); } //====================================================== // Update Arms Log //====================================================== if( !empty($_GET[action]) AND $_GET[action]=="buyarms" ) { $str = add_arms( $user, $_GET[aid], decrypt_url($_GET[prc]), decrypt_url($_GET[amt]) ); } if( !empty($_GET[action]) AND $_GET[action]=="sellarms" ) { $str = remove_arms( $user, $_GET[aid], decrypt_url($_GET[prc]), decrypt_url($_GET[amt]) ); } and this works great the issue is in firefox after lets say i buy something everything updates the url is encrypted but as soon as i click any link to another page or on same page it submits again but its fine in IE the second code is a include file which is on every page so may be because this any idea or advice please Link to comment https://forums.phpfreaks.com/topic/162767-firefox-issue-submitting-twice/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.