Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. That was quite an exciting read :) Glad you got it done Len.. now you won't have to bug me about it :p BTW Len, your first posts left out information that a programmer needs to give you an answer. That's part of why it took so long. PHP files, variables, forms, HTML, they all have different rules for where you need to use slashes. And ereg_replace() has different rules again. And magic_quotes complicates it further, though it was intended to simplify it. It's a mess, but you just have learn them all..
  2. I know this is a difficult question. I will bump this once only in the hope that someone has had to deal with php's forking behaviour before :)
  3. I have a script which opens a connection with pg_connect(), and then forks some children. Unfortunately, when the first child exits, the database connection gets closed. The parent then gets a "server closed connection unexpectedly" warning on the next database query. Is there some way to hide this connection from the child so it doesn't close it on exit? I am using PHP 4.3.10 on Linux
  4. You can do this: [code]$page = $_GET['page']; $bad_strings = array(   "://",   "../", ); foreach ($bad_string as $b) {   if (strpos($page, $b) !== false) {     die("I'm not including that!!");   } } [/code] Another thing you can do is: [code]$page = $_GET['page']; if (ereg("[^a-zA-Z0-9]", $page)) {   die("I'm not including that!!"); } [/code] That will reject anything which is not a letter or a number. If you want to allow other characters, you can include them in that regexp. In particular, this rejects ".", "/", and anything else needed to include something from another directory. Even better is: [code]$page = $_GET['page']; $allowed = array(   "news",   "forum", ); if (!in_array($page, $allowed)) {   die("no no no no no, a million times no!"); } [/code] These are all implementations of kenrbnsn's suggestions. Toonmariner, you may have a problem with files like "../../../../../etc/passwd".
  5. I have a script which opens a connection with pg_connect(), and then forks off several children. When the children are finished, they exit. Unfortunately, these children inherit the parent's postgres connection, and they close this connection when they exit. Is there any way to stop the children from closing the connection?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.