Jump to content

Selecting part or all of an item


u214

Recommended Posts

Hey guys. Ok, let's say I have this query: "SELECT * FROM playerbans WHERE BannedName = 'something' OR BannedIP = '192.168.0.1'"

 

How can I make the "BannedIP" be detected all or just part of it? Lets say, "192.168.0" Will still detect that field?

Link to comment
Share on other sites

I've only run cursory tests on this, and you'll need to be at least somewhat familiar with subnet masks and bitwise operations to understand what it's doing, but here goes.

 

$mask = '255.255.255.0';
$address = '192.168.0.1';
$query = "SELECT * FROM playerbans WHERE BannedName = 'something' OR ( INET_ATON('$mask') & INET_ATON(BannedIP) ) = ( INET_ATON('$mask') & INET_ATON('$address') )";

Link to comment
Share on other sites

I appreciate both answers and the code posted. Not exactly what I'm looking for. I should've explained my problem more in detail.

 

Let's say I have this rows:

 

(BannedName)(IP)                          (Reason)                                (Date)                                      (Admin)

bash1tro.     192.168.0.111       No Reason Give                   June 28, 2011 - 19:41:49     Admin

bash1troo.   192.168                 No Reason Given                 June 28, 2011 - 19:45:08     Admin

bash1tro..   192.168.0.112       No Reason Given                 June 28, 2011 - 19:45:09     Admin

--

As you can see the similarities. The player is still joining the server. Is there a syntax like "strfind" but on that query?

Link to comment
Share on other sites

Lets just say you do make a query with finding ip's starting with 192.168 (first 2 positions), don't you think you'll not be allowing too many people in that entire ip range?

 

Even then sadly if they have a dynamic ip they can always come back, or change their static through their isp.

 

If this person is that much a pain, just block them via htaccess and that range for a while, until he forgets about you.

 

as an example

 

Deny 69.60.114.0 - 69.60.114.255

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.