Page 1 of 1

mrz plz !!!!

Posted: Thu Oct 15, 2009 6:08 pm
by mohamed
i use mikrotik v3.13 on pc i have hotspot and
i have error in this script its if he found the name in the dns cache he put it in wep proxy and when the scrept run again he Repeat the name in the wep proxy like the pic
repaet.JPG


and this is the script


:foreach i in=[/ip dns cache find] do={:local bNew "true";:local cacheName [/ip dns cache all get $i name] ;:put $cacheName;:if (([:find $cacheName "mikrotik"] != 0) || ([:find $cacheName "cnn"] != 0)) do= {/ip proxy access add dst-host= $cacheName redirect-to=google.com};:if ( $cacheName = [/ip proxy access find dst-host=$cacheName] ) do={:set bNew "false"; }}}}


and i need another script if i have many user like:

1- name=a profile=dufalt
2- name=b profile=new
3- name=c profile=dufalt
4-name=d profile=dufalt
5-bame=e profile=new

i need script to put it in user profile script onlogin do if the user login set profile=another profile

and thankes for any help

Re: script error ??

Posted: Sat Oct 17, 2009 10:18 pm
by mohamed
i tray to do this but ihave small error



:foreach i in=[/ip hotspot user find profile=defalt] do={:if ([/ip hotspot active get [find user=[/ip hotspot user get $i name] uptime <1m ]) do={/ ip hotspot user set [/ip hotspot active get $i user] profile=30}}}


????? :( :(

Re: mrz plz !!!!

Posted: Mon Oct 19, 2009 3:58 pm
by mohamed
????? :( :( :(

Re: mrz plz !!!!

Posted: Mon Oct 19, 2009 4:05 pm
by mrz
You have to check if entry is already added to proxy access. Check this example:
http://wiki.mikrotik.com/wiki/Scripting ... c_websites
It uses address lists, but concept is the same. Compare if entry is already added, if not then add.

Re: mrz plz !!!!

Posted: Mon Oct 19, 2009 4:47 pm
by mohamed
You have to check if entry is already added to proxy access. Check this example:
http://wiki.mikrotik.com/wiki/Scripting ... c_websites
It uses address lists, but concept is the same. Compare if entry is already added, if not then add.

first thanks for your answer
but i need to add in proxy dont add in firwall



:foreach i in=[/ip dns cache find] do={:local bNew "true";:local cacheName [/ip dns cache all get $i name] ;:put $cacheName;:if (([:find $cacheName "mikrotik"] != 0) || ([:find $cacheName "cnn"] != 0)) do= {/ip proxy access add dst-host= $cacheName redirect-to=google.com};:if ( $cacheName = [/ip proxy access find dst-host=$cacheName] ) do={:set bNew "false"; }}}}





:foreach i in=[/ip dns cache find] do={
:local bNew "true";
:local cacheName [/ip dns cache all get $i name] ;
# :put $cacheName;

:if (([:find $cacheName "rapidshare"] != 0) || ([:find $cacheName "youtube"] != 0))
do={

:local tmpAddress [/ip dns cache get $i address] ;
# :put $tmpAddress;

# if address list is empty do not check
:if ( [/ip firewall address-list find ] = "") do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=restricted disabled=no comment=$cacheName;
} else={
:foreach j in=[/ip firewall address-list find ] do={
:if ( [/ip firewall address-list get $j address] = $tmpAddress ) do={
:set bNew "false";
}
}
:if ( $bNew = "true" ) do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=restricted disabled=no comment=$cacheName;
}
}
}
}



can you help me ??

Re: mrz plz !!!!

Posted: Fri Oct 23, 2009 9:33 pm
by mohamed
thanks i do it :lol: :lol: :lol:


:foreach i in=[/ip dns cache find] do={
:local bNew "true";
:local cacheName [/ip dns cache all get $i name] ;
# :put $cacheName;

:if (([:find $cacheName "adult"] != 0) || ([:find $cacheName "porn"] != 0)) do={

:local tmpName [/ip dns cache get $i name] ;
# :put $tmpName ;

# if address list is empty do not check

:foreach j in=[/ip proxy access find ] do={
:if ( [/ip proxy access get $j dst-host] = $tmpName ) do={
:set bNew "false";
}
}
:if ( $bNew = "true" ) do={

/ip proxy access add disabled=no comment=$cacheName dst-host=$tmpName action=deny ;
}
}
}