Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Generate the array based on which files are available. $page = 'pages/' . $_GET['page'] . '.php'; $pages = glob('pages/*.php'); if (!in_array($page, glob('pages/*.php'))) { die('invalid page'); // substitute with proper error handling } include $page; Not tested, but should work.
  2. Things that are in $_REQUEST will never be integers. They are always strings. is_int checks the data type, not the contents. You can use ctype_digit to solve your problem.
  3. You'll have to be careful with that approach. For instance, you risk censoring "grass" to "gr***" when you censor "ass". You can "fix" that like this: $badwords = array('bad1', 'bad2', 'bad3', 'ass'); $text = 'This is a test. Ass. Grass. bad1.'; function filterBadwords($text, array $badwords, $replaceChar = '*') { return preg_replace_callback( array_map(function($w) { return '/\b' . preg_quote($w, '/') . '\b/i'; }, $badwords), function($match) use ($replaceChar) { return str_repeat($replaceChar, strlen($match[0])); }, $text ); } echo filterBadwords($text, $badwords); Output is: This is a test. ***. Grass. ****.
  4. You can split a string by a delimiter using explode.
  5. You might also want to lookup SQL injections and XSS so you can close those security holes. They're mentioned in this tutorial: http://www.phpfreaks.com/tutorial/php-security
  6. The way that PHP converts strings to integers is by reading all characters until the first non-digit character is found. This means that (int)"0xFF" becomes 0 and not 255. See: http://dk.php.net/manual/en/language.types.string.php#language.types.string.conversion
  7. Use the curl_multi_*() functions to download in parallel.
  8. Doesn't it allow you to pass parameters to the programs so you can do something like "C:\php5\php.exe C:\path\to\script.php"?
  9. You could start with spending your time on research instead of spending it on bumping this topic.
  10. Assuming that username is primary key (or just any key) in the other table, that would be perfectly fine.
  11. Did you even try running the code to see what happens?
  12. Then that is what is in the XML document...
  13. XML is plaintext. You can open it in any editor.
  14. What exactly makes you think you're entitled to multiple voices? Basically they should be sued because you like Mike's voice better than Anna's? Please stop trolling.
  15. Didn't you already receive a response? Is there anything else you need help with?
  16. If you give me a deterministic way of determining that with only that information available, I'll write a rewrite rule for you.
  17. I absolutely lost it. LOL, the letter u is miles away from the letter a on a keyboard. What where you thinking? If he is using Dvorak, both of them are at the home row, and he is likely to rest his left hand on both of those keys
  18. Use move_uploaded_file; it's only restricted on the destination.
  19. PHP is written in C. You can read the source code here: http://svn.php.net/php/php-src/trunk/
  20. That's not what register_long_arrays means. If you set this to on, then the $HTTP_*_VARS superglobal arrays will be populated. Those are deprecated, by the way.
  21. For the sake of readability, I'd just use a regex in this case: if (!preg_match('#^\+\d+$#', $number)) { // it's invalid } Alternately: if ($number[0] != '+' || !ctype_digit(substr($number, 1))) { // it's invalid }
  22. So 1.234e56 is a valid phone number in your eyes?
×
×
  • 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.