Community discussions

MikroTik App
 
mohamed
newbie
Topic Author
Posts: 33
Joined: Sat Apr 25, 2009 11:52 am

mrz plz !!!!

Thu Oct 15, 2009 6:08 pm

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
You do not have the required permissions to view the files attached to this post.
Last edited by mohamed on Mon Oct 19, 2009 3:57 pm, edited 1 time in total.
 
mohamed
newbie
Topic Author
Posts: 33
Joined: Sat Apr 25, 2009 11:52 am

Re: script error ??

Sat Oct 17, 2009 10:18 pm

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}}}


????? :( :(
 
mohamed
newbie
Topic Author
Posts: 33
Joined: Sat Apr 25, 2009 11:52 am

Re: mrz plz !!!!

Mon Oct 19, 2009 3:58 pm

????? :( :( :(
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: mrz plz !!!!

Mon Oct 19, 2009 4:05 pm

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.
 
mohamed
newbie
Topic Author
Posts: 33
Joined: Sat Apr 25, 2009 11:52 am

Re: mrz plz !!!!

Mon Oct 19, 2009 4:47 pm

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 ??
 
mohamed
newbie
Topic Author
Posts: 33
Joined: Sat Apr 25, 2009 11:52 am

Re: mrz plz !!!!

Fri Oct 23, 2009 9:33 pm

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 ;
}
}
}

Who is online

Users browsing this forum: No registered users and 7 guests