Digital Paint Discussion Board

Development => General Development => Topic started by: jitspoe on May 01, 2007, 03:29:34 AM

Title: Looking to help? PHP/MySQL/Apache stuff.
Post by: jitspoe on May 01, 2007, 03:29:34 AM
I've got a lot on my plate and hate spending time to research things like this when I can be coding, so if you know/can look up some of these things, I'd appreciate it:

- Apache: Why is it that if I extract a downloaded tar/zip I get 403 Forbidden even though the owner/permissions are the same as everything else?  If I re-tar and untar the data it works fine.
- Apache: Possibly related to the above.  Symlinks aren't working outside of the /var/www/html directory.  I'm trying to point htm/files/maps to /home/admin/paintball2/pball/maps to conserve space.  It worked fine on the old server and I've duplicated the settings in the httpd.conf and .htaccess files.  Also, it doesn't seem to be reading the settings from the htaccess file (but symbolic links should work regardless).
- PHP: Reverse dns.
- Mysql: query including everything with a timestamp field newer than 1 hour.
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: b00nlander on May 01, 2007, 03:56:49 AM
- Mysql: query including everything with a timestamp field newer than 1 hour.

SELECT * FROM table WHERE timestamp_field > NOW()-10000;

-------------------------------------------

- PHP: Reverse dns.


<?
$ipAddress = "193.99.144.85";
   
    $host = @gethostbyaddr($ipAddress);
    if ($host == $ipAddress) {
      print "unable to resolve host";
    }
    print $host;
?>
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: jitspoe on May 01, 2007, 02:38:09 PM
Thanks, b00nlander.  Where does the 10000 come from, though? HMMSS format?

Quote
SELECT * FROM table WHERE timestamp_field > NOW()-10000;
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: b00nlander on May 01, 2007, 03:24:35 PM
yup. timestamp is stored as "YYYYMMDDHHMMSS", basically
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: Smokey on May 01, 2007, 03:36:18 PM
b00n took care of everything I can help with
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: jitspoe on May 03, 2007, 05:26:30 PM
I don't think that query worked right.

Code: [Select]
$query = "SELECT `ip`, `port` FROM `dplogin_serverinfo` WHERE `lastheartbeat` > NOW()-10000;";
Still returning everything.

The apache stuff is taken care of now.
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: y00tz on May 03, 2007, 09:05:08 PM
Could the database server and php (?) server system clocks be off?
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: jitspoe on May 03, 2007, 09:42:32 PM
Nevermind on that.  I'm not sure why it didn't work before, but now it does.  I must have done something wrong or something didn't update.

Now... what's the most efficient way to do a wildcard comparison (or possibly regular expression) when the mask is in the database.  For example, if I have a field containing things "*.baddomain.com" (or %.baddomain.com if that's preferred) and I want to see if the current host name matches any of those.  Do I need to query all those values and compare, or is there a handy WHERE clause that can handle that.  Does "LIKE" work both ways?
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: Smokey on May 04, 2007, 02:57:45 PM
Could the database server and php (?) server system clocks be off?
They all run off the main system clock, lol.
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: y00tz on May 04, 2007, 03:33:44 PM
Smokey: We've always hosted our database and web servers on different systems...I didn't think about it, but I guess NOW() must be a MySQL function, and I thought it to be a PHP function.


Jitspoe:
You mean like..
Code: [Select]
sql  > SELECT '<--host domain-->' REGEXP '^( <--This is a field of bad domains-->)*$';
something like this?
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: jitspoe on May 04, 2007, 04:37:35 PM
Can I use a field for the regular expression?  Say the field name is "trigger".  Would that be:

"SELECT `id` FROM `dplogin_bantriggers` WHERE '$domain' REGEXP '^(`trigger`)$';"?

Everything I've seen goes the other way around: WHERE `field` REXEP '.*whatever.*';
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: Smokey on May 05, 2007, 07:39:59 AM
Can I use a field for the regular expression?  Say the field name is "trigger".  Would that be:

"SELECT `id` FROM `dplogin_bantriggers` WHERE '$domain' REGEXP '^(`trigger`)$';"?

Everything I've seen goes the other way around: WHERE `field` REXEP '.*whatever.*';
I hate regexp. Poor jits.
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: jitspoe on May 05, 2007, 09:10:07 PM
Regexp is awesome.  I'm just not sure if I can use it backwards like that.
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: Smokey on May 06, 2007, 11:35:07 AM
Regexp is awesome.  I'm just not sure if I can use it backwards like that.
Its awsome, if you can understand it. Never took the time to learn what $@%^&*( means.
Title: Re: Looking to help? PHP/MySQL/Apache stuff.
Post by: lekky on May 07, 2007, 07:04:49 AM
regex is a validation lifesaver.