MOD: BlockMod (keep certain people IN ór OUT of your store)

I’ve written a nice, quick & dirty (no warranty) mod to either (choose):



[COLOR=“red”]-Allow access to certain ip’s or dns’es[/COLOR]



[SIZE=“3”]OR[/SIZE]



[COLOR=“Red”]-Ban/Block certain ip’s or dns’es[/COLOR]



Can come in handy.

The Mod will also send you an email, if wanted.



RTFM (well, more RTFC (comments)) and all becomes clear.





```php # BlockMod, Quick & Dirty, NWSco 2007:

Used for testing your store: specify the ip/dns that ARE allowed to enter your store.

Dont forget to add your Payment-Providers IP/DNS in case you use them!

To disable the whole functionality, simply set $BlockMod to false

------

You can also use this mod as a ban/blockfilter for LIVE stores: change BlockModForTestingPurposes to false!

#



$BlockMod = true; //Use BlockMod?

$BlockModForTestingPurposes = true; //true: Only the specified ip/dns’s are ALLOWED

//false: Specified ip/dns’s are NOT ALLOWED

$BlockEmailNotification = “”; //If you fill in your email address, blocking-details will be emailed (leave empty to disable emailing-option)



//depending on the setting for “$BlockModForTestingPurposes”: enter the ip/dns for access or blocking: (add lines as needed!)

$address[] = “localhost”;

$address[] = “127.0.0.1”;

$address[] = “bill.microsoft.com”;

$address[] = “test.google.com”;

$address[] = “89.106.184.19”;



if ($BlockMod) { $address_found = false;for ($uip = 0; $uip < count($address); $uip++) { if (getenv(‘REMOTE_ADDR’) == $address[$uip] || strtolower(gethostbyaddr($_SERVER[‘REMOTE_ADDR’])) == strtolower($address[$uip])) { $address_found = true; break; } }

if ((!$address_found && $BlockModForTestingPurposes) || ($address_found && !$BlockModForTestingPurposes)) { if ($BlockEmailNotification!=“”) { @mail($BlockEmailNotification,“BlockMod results on “.$_SERVER[‘SERVER_NAME’],“BlockMod on “.$_SERVER[‘SERVER_NAME’].” detected access from:”.chr(13).chr(13).” --IP:”.getenv(‘REMOTE_ADDR’).chr(13)." --DNS:".gethostbyaddr($_SERVER[‘REMOTE_ADDR’])); } die(“No access.”); } }



/*END BlockMod */ ```





To implement:

Open index.php

paste the code BEFORE this line (around 34)

```php DEFINE (‘AREA’, ‘C’); ```





Improvements are always welcome. It also needs session-checking in the future, to avoid hammering or so…ah well…

Of course, all can also be fitted into the backend with a nice interface. Maybe someone has time for this? be my guest.

Hi nwsco



And thanks, another Quick & Dirty. :rolleyes:

Great addition!

Many thanks

Francesco

Is this being used with no problems. Seems like a great mod.



Also, to make this mod work do you have to hard code it into the index.php for every I.P adresses you wish to ban.

works great yes.

this needs to be put hardcoded in index.php yes, or you can put it in an include or so.

as i said: i made it quick&dirty: it can of course be made into a real MOD,

administered from the backend…

wow another nice mod that reduces of development work for the dev team and can be added as a default what does the admins think :slight_smile: with developer approval offcourse :stuck_out_tongue:



thnx a lot for this mod ill try to try it out…



chahine

Then again if you use cpanel you can block ip address from there ?

that is right yes.

however, i made this one that it:

-also handles dns’es instead of ip

-can be used other way around (only give access instead of block)

-sends a mail if wanted in case of access/block as needed



if many peeps are interested (not just one), i can make a nice

backend-administered mod of this, that also can take partial dns’s or so?

I’ve been working on this, and made a beautiful MOD out of it,

called AccessFilter™.

It does a LOT, blocking or just allowing, even do partial matches on

IP or DNS and also Loginnames, sends beautiful emails etc.!

Too many options to mention here, just a sneak preview below.

ETA asap. It’s weekend :stuck_out_tongue:



Hi nwsco



It is a beautiful MOD, looks like some hard works gone into it, very nice m8.

thx m8.

I’ll post soon, just needs extensive tesing.



b.t.w. it will use session-checking as well, so will only check once per visit.

I’m just finished adding logging-functions, very handy, see new screenie above.

[quote name=‘nwsco’]thx m8.

I’ll post soon, just needs extensive tesing.



b.t.w. it will use session-checking as well, so will only check once per visit.

I’m just finished adding logging-functions, very handy, see new screenie above.[/QUOTE]



wow im impatient for you to finish it and test it :slight_smile:



looks hmmmm cant find the word to discribe it :wink:





BTW the one posted above works perfect for my test site…

chahine

thanks.

Well, this one is completely rewritten and a heavyweight compared to the one i posted.

its got loads of functions. i’m sure all will be pleased.



it now works with sessions as well, so the filter will only be used when entering the site, BUT will be triggered again when visitor should log in.

Logging, emailing…even sends you a mail when you forget to

give the logfile writepermissions (after it tries it self first!) etc.etc.



as said: the mod is finished (loads of great feautures), but i’ll start testing upcoming week.

I did some preliminary testing and all seems to work fine.

before releasing i would like to have one ally that can do some

testing etc. as well.

Normally i wouldnt do this, but if this baby doesnt work, so

does(nt) your shop! :o)))



I’d prefer one of the regulars here with a techie background? anyone?

info:screenshot updated.



still no tester found…any of the regulars here?

nwsco i had a taught i dont know how it easy or hard it would be to implement but why not use as well the country list that is available in cs cart and use that as well as filter. and have a cross check of ip verses country.



the other is maybe instead of blocking purely it would be good to send them to another page (or as an option for specific blocks) of choice that is created and explanining why they were blocked.



but whatever u decide i give u 10 thumbs :slight_smile: up for this mod…



thnx

chahine

thx chahine.

as to ip-per-country: those tables need constant updating (already made that stuff once) and makes it more heavy for clients…someone can be my guest to add that later: personally i dont see a reason for that…maybe when i’m 110% bored lol.



sending to another page when blocked is already implemented in this mod.



still looking for testers before releasing…

nwsco i dont mind doing some basic testing based on my knowledge…



ill not be able to test out techi style but will try to give it a more average user approach and let you know if any issue jump in.



let meknow.



chahine

[quote name=‘nwsco’]I’ve been working on this, and made a beautiful MOD out of it,

called AccessFilterâ„¢.

It does a LOT, blocking or just allowing, even do partial matches on

IP or DNS and also Loginnames, sends beautiful emails etc.!

Too many options to mention here, just a sneak preview below.

ETA asap. It’s weekend :stuck_out_tongue:



[url]http://mediacenterweb.com/images/AccessFilter.gif[/url][/QUOTE]



Only after quoting this post (in this reply) I saw that there was supposed to be a gif file here… So I guess this one wasn’t finished… :stuck_out_tongue:

CS-Cart incorperated it into 1.3.5, because it was worthy.