Jump to content

heckenschutze

Members
  • Posts

    257
  • Joined

  • Last visited

    Never

Contact Methods

  • ICQ
    1

Profile Information

  • Gender
    Male
  • Location
    Australia

heckenschutze's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. No, but there are regular expressions, take your pick between POSIX or PCRE regex
  2. If you want to search for the id: <?php $h = NULL; $cols = array(); $line = ""; if(($h = @fopen('file.txt', 'rb')) === FALSE) die('Failed to open some file'); while(($line = @fgets($h)) !== FALSE) { $cols = explode('\t', $h); /* $cols[0] is the fileid */ /* $cols[1] is the filename */ } fclose($h); ?> Search or do whatever.
  3. Don't do that, what if the user used a proxy server? Or several proxy servers? Some ISPs even use proxy servers, so your user would be pretty pissed off if you told them their account had been 'hacked' when they try to log in. Just chuck an extra field in your user table, 'lastAction' or something. Which stores a timestamp of their last action, if someone else tries to login in a time say greater than 'lastAction' + timeout then let them (and destroy the original session), else don't.
  4. I don't see where you send the header of the content type... that it's jpeg header("Content-type: image/jpeg"); Or something
  5. Nothing really to fix it, $hours = diffHours(strtotime($row3['datetillcompletion']), time()); Does that work? you just need to pass 2 timestamps to diffHours. strtotime() converts a string to a timestamp. You should consider changing your database so dates/times are stored as unix timestamps, you can get the current time with time().
  6. diffHours() will tell you the difference between 2 unix timestamps, in hours. A unix timestamp is how many seconds have past since the UNIX EPOCH (1970), once you realize that it's pretty easy. You should be storing the timestamp in the database, not a string.
  7. $hours = diffHours($row['datetillcompletion'], time()); Returns the amount of hours between the 'datetillcompletion' and the current time. Note: It really helps if you understand unix timestamps, no need to convert it to a string, then back to a timestamp.
  8. Just for example, so the times were different Can chuck it in a function for a one liner, function diffHours($a, $b) { return (abs($a - $b) / pow(60, 2)); } abs() because we only care about the difference in scalar terms.
  9. $time1 = time(); $time2 = time() + 328523; /* some random number */ $dSecs = abs($time2 - $time1); $dHours = $dSecs / pow(60, 2); Something like that, there is probably a PHP function to do this...
  10. I've written something exactly like that in C before, it's very easy - just it's harder in PHP, being scripted etc. But try and structure it well, use an array rather than a string.
  11. I'd suggest starting again for the date/time, you seem to be making it hard on yourself. A unix timestamp the the no. of seconds after 1970. $ourTime = time(); $gameTime = array( 'year' => date('Y', $ourTime) + 2404, 'month' => date('m', $ourTime), 'day' => date('d', $ourTime)); echo 'Game year is ' . $gameTime['year']; Set it out something like that, you can change $ourTime to the start time, and just factor in how far in days, seconds, years or whatever the game time is ahead. No need to keep going back and forth.
  12. Why make it so hard on yourself? $realTime_current = mktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y")); Is the same as $realTime_current = time();
×
×
  • 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.