LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Anybody having this issue with PHP scripts using forms? (http://www.linuxquestions.org/questions/linux-general-1/anybody-having-this-issue-with-php-scripts-using-forms-4175443097/)

Elmware 12-27-2012 07:10 AM

Anybody having this issue with PHP scripts using forms?
 
So I wrote a simple PHP script which uses a form. The form submits fine if there is less than 113 characters, however, if I submit 113 or more characters in the field, I keep getting a 403 - forbidden message.

If it's of any help, here is the actual code:
Code:

<?php
$script_file = basename($_SERVER['SCRIPT_NAME']);
$script_path = str_replace("/".$script_file, "",$_SERVER['SCRIPT_FILENAME']);

if (isset($_POST['codedMsg'])) $codedMsg = $_POST['codedMsg'];
  else $codedMsg = "";

echo '<html>
<head>
<title>
Binary Decoder
</title>
</head>

<body>
<form method="post" action="'.$script_file.'">
<b>Binary:</b><br>
<textarea name="codedMsg" cols="80" rows="5" style="border: #000000 1px solid;"></textarea>
<br><input type="submit" value="Decode">
</form>'."\r\n";

// Strip entry to bare 0s and 1s.
for ($i = 0; $i < 48; $i++) $codedMsg = str_replace(chr($i), '', "$codedMsg");
for ($i = 50; $i < 256; $i++) $codedMsg = str_replace(chr($i), '', "$codedMsg");

if (is_numeric($codedMsg)) {
  $len = strlen($codedMsg);
  $fraLen = $len / 8;
  $totChars = floor($fraLen);
  for($i = 0; $i < $totChars; $i++) {
    $num = $i * 8;
    $binChar[] = bindec(substr("$codedMsg", $num, 8));
  }
// substr
  echo "<b>Decoded:</b><p>";
  for ($i = 0; $i < count($binChar); $i++) echo chr($binChar[$i]);
  echo "</p>
</body>
</html>\r\n";
}
?>

I think the issue is with the server itself though.

I've even tried to lookup this problem on Google, and the results are from messages posted about mod_secure issues over a couple years ago, which is different than this problem.

rylan76 12-27-2012 07:52 AM

Check your

post_max_size

PHP parameter? What is it set to?

113 chars sounds obscenely small though, but the above config setting is the first place to start checking?

What "kind" of PHP are you running? One you compiled yourself or a binary package?

Elmware 01-04-2013 12:38 AM

Thankks for the response.

Apparently, it shows in PHP.ini as:
Quote:

post_max_size = 8M
Both PHP and HTTPD were installed using the Software Management that comes with fedora 16. Updates are done whenever Apper notifies me.


All times are GMT -5. The time now is 07:31 AM.