Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. I'd suggest something like this that enforces day/month ranges to be acceptable. For example, this will accept 07-11-2011 but will not accept 32-13-2011 or other dates that are obviously wrong. You could use the same technique as used for day and month ranges to constrain the years to something reasonable as well, but I don't know what your application expects. It will still allow for non-existant dates, so you'll still require further validation, but it's better than allowing dates like 00-99-0000. ((0[1-9])|(1|2[0-9])|(3[01]))-((0[1-9])|(1[0-2]))-(\d{4})
  2. Probably. Something like this: $vals = array(); while ($sql -> fetch()) { $vals[] = $form[$val]; } var_dump($vals);
  3. You can call an operating system program using exec(). So you could make a simple script that runs the script using exec and displays a message stating that it was run. Something like this: exec('/usr/bin/php -f /path/to/script/yourscript.php &');
  4. Run your script from the command line: php -f myscript.php Typically a script like that would be setup on some schedule. On a linux host you would do this with cron.
  5. You make the dateTime with the timezone for that matches the current time. Then you set the timezone to IST and display it.
  6. I suppose this varies by location, but the most in demand frameworks/cms in my experience are: zend framework symfony code igniter cakephp drupal joomla If you're going in as an entry level developer I don't think there's any expectation that you would already be an expert in a framework, and certs/training is pretty expensive. If anything get a zend cert and a mysql cert. If I were going to recommend a framework with a lot of momentum right now, I'd point you to symfony.
  7. Yes, that is the tradeoff, but the theory there would be that an active session is going to move off a page in a reasonable amount of time. If your javascript inactivity timeout is 3 minutes, you might allow a meta refresh of 10.
  8. You can use a meta refresh with a somewhat longer timeout, or just don't allow them on the site with javascript turned off.
  9. I doubt seriously that you need to do 0777. Who owns the directory? Apache? I'd try 0700 or 0770. There's no reason to make it world writeable.
  10. Your code needs to actually look at the result of the count(*) query. $query = "SELECT count(*) as countof FROM mytable WHERE ip = '{$_SERVER['REMOTE_ADDR']}'"; $result = mysql_query($link,$query); if ($result) { $row = mysql_fetch_assoc($result); if ($row['countof'] > 0) { // don't allow signup } else { // do signup } }
  11. Yes, you should have your standard logout url take care of "logging out" and destroying the session. Something along the lines of: session_start(); session_unset(); session_destroy(); Your on the right track with the javascript timeout. Basically you want the timeout function to redirect to your logout url. You also need to capture events and reset the timer anytime there is a mousemove, keypress or keydown event. Using a javascript library like jquery or prototype will make things much easier if you are challenged as to how to accomplish the javascript.
  12. I will consult my magic eightball and get back to you on this later. See: https://www.msu.edu/~vandrag2/8-ball.html?pagewanted=all
  13. This shows you how to do it (change from one timezone to another) once you created the datetime object with a PST timezone: http://us.php.net/manual/en/datetime.settimezone.php
  14. In PHP you can do this with the datetime object. datetime
  15. I doubt seriously this is the best way to handle whatever it is that you are trying to do, however it can be accomplished. $i=0; while ($sql -> fetch()) { $name = 'num' . $i++; $$name = $form[$val]; } // now you'll have variables $num0... x for ($x = 0; $x echo '$num'.$x . ' = ' . ${'num'.$x} . ' '; }
  16. $query = "SELECT count(*) as countof FROM iptablename WHERE ip = '{$_SERVER['REMOTE_ADDR']}'"; Fetch the result. Really bad idea unless you don't care about stopping people who share an IP (NAT'd) from signing up.
  17. You're just on entirely the wrong path. Automatic logout needs to be accomplished with javascript, not by trying to game the session garbage collection.
  18. This is the type of problem best run from CLI where you don't have the same type of concerns in regards to timeouts and things of that nature.
  19. They certainly won't be rare, considering the problems with the current code.
  20. Nice stuff. Your youtube abstract page has some weird characters in there, you should look at. The opengl viewer would benefit from a description of the challenge, and what you accomplished. Overall, an impressive array of disconnected projects, and the design of the site is nicely done. I'm not sure about the right align of the text in the right column however.
  21. You need to explain what you want more clearly.
  22. The typical solution is to use json, which is a data structure that both php and javascript can work with.
  23. This is simply an implementation of this: http://en.wikipedia.org/wiki/HMAC
  24. This is bad too: $queryShop[] = "UPDATE `poke_balls` SET `stock` = ".($result['stock']-$amount)." WHERE `name`='".$name."'"; It should be stock = stock - $amount. The database takes care of concurrency. Let's say that person A and person B both do these queries around the same time, so they each see that the stock is 5 balls. Person A buys 2 balls. 5 balls - 2 balls = 3 balls. A split second later the 2nd person runs their update. 5 balls -1 balls = 4 balls. Now inventory shows 4 balls, even though 3 balls have been delivered. The database is already atomic and handles concurrency. That's just wrong-headed code.
  25. Yeah I agree, it's like they are praying that their logic works, but if it doesn't, well woops, at least i can only f-up one record! Silly stuff.
×
×
  • 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.