miva masochists guild

home
Merchant
FAQ
Links
News
Rants
Info
 

IP Filter

An IP filter is a small snippet of code you can place in any Miva Script to prevent access to the script based on the TCP/IP address of the user calling the script. In order to use an IP filter you must know the IP address or range of IP addresses that you or your approved people will be coming from to access the script file (like ADMIN.MV).  You can find out your current IP address lots of ways (all are Windows examples), like running WINIPCFG.EXE or running a 'route print' command in a DOS window. Or you can call your ISP and simply ask them what range of IP addresses they assign to their dial-up lines. Be sure to explain who you are and why you are asking.  Either way, let's assume you access the internet through one account with AT&T Worldnet (good security choice, their entire network is all behind a firewall) and another account with 'My ISP". You dial each a gadzillion times and discover that your dial-up accounts are always assigned (bogus numbers in the examples):

AT&T Worldnet        134.243.186.*
My ISP                     206.71.2.*

Here is an example which could be placed most anywhere using that IP info:

<MvIF EXPR="{ (134.243.186. CIN remote_addr) OR (206.71.2. CIN remote_addr) }">
        <MvELSE> 
        <MIVA STANDARDOUTPUTLEVEL="text,html">
        <HEAD><TITLE>Access Denied</TITLE></HEAD><BODY>
        You are not permitted to access this page from your location.
   
         </P></BODY></HTML>
        <MvEXIT>
</MvIF>

All it does is check to see if the user is coming from an IP address that you have permitted. If not, it gives a message and exits the script. Yes pure-breds, it could be spoofed. Put things in context. 

Doormat Alarm

You can add a snippet to any script which notifies you when someone has done something in your script. One sample would be:

<MIVA STANDARDOUTPUTLEVEL = "text"> 
<MvSMTP 
      TO = "me@mydomain.com" 
      FROM = "this_script@yourdomain.com" 
      SUBJECT = "Script Access" 
      MAILHOST = "mail.yourmailhost.com">

The script <MvEVAL EXPR="{ documenturl }">was accessed at:

Time: <MvEVAL EXPR="{ tm_hour $ ':' $ tm_min }"> on <MvEVAL EXPR="{ thedate_f }">
From: <MvEVAL EXPR="{ remote_addr }"> 
HostName: <MvEVAL EXPR="{ remote_host }">
Ident: <MvEVAL EXPR="{ remote_ident }">
User: <MvEVAL EXPR="{ remote_user }">

</MvSMTP> 

Remember that this snippet would send mail every time the script was accessed. Stick it in an <MvIF> loop to control when it does its thing.

 

   
hosted by driftwood