Author Topic: Looking to help? PHP/MySQL/Apache stuff.  (Read 2981 times)

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Looking to help? PHP/MySQL/Apache stuff.
« on: May 01, 2007, 01: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.

b00nlander

  • Autococker
  • Posts: 784
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #1 on: May 01, 2007, 01: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;
?>
« Last Edit: May 01, 2007, 02:52:37 AM by b00nlander »

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #2 on: May 01, 2007, 12:38:09 PM »
Thanks, b00nlander.  Where does the 10000 come from, though? HMMSS format?

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

b00nlander

  • Autococker
  • Posts: 784
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #3 on: May 01, 2007, 01:24:35 PM »
yup. timestamp is stored as "YYYYMMDDHHMMSS", basically

Smokey

  • Autococker
  • Posts: 1172
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #4 on: May 01, 2007, 01:36:18 PM »
b00n took care of everything I can help with

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #5 on: May 03, 2007, 03: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.

y00tz

  • Autococker
  • Posts: 2742
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #6 on: May 03, 2007, 07:05:08 PM »
Could the database server and php (?) server system clocks be off?

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #7 on: May 03, 2007, 07: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?

Smokey

  • Autococker
  • Posts: 1172
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #8 on: May 04, 2007, 12:57:45 PM »
Could the database server and php (?) server system clocks be off?
They all run off the main system clock, lol.

y00tz

  • Autococker
  • Posts: 2742
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #9 on: May 04, 2007, 01: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?

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #10 on: May 04, 2007, 02: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.*';

Smokey

  • Autococker
  • Posts: 1172
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #11 on: May 05, 2007, 05: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.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #12 on: May 05, 2007, 07:10:07 PM »
Regexp is awesome.  I'm just not sure if I can use it backwards like that.

Smokey

  • Autococker
  • Posts: 1172
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #13 on: May 06, 2007, 09: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.

lekky

  • Autococker
  • Posts: 2449
Re: Looking to help? PHP/MySQL/Apache stuff.
« Reply #14 on: May 07, 2007, 05:04:49 AM »
regex is a validation lifesaver.