Block annoying numbers on freeswitch - freeswitch

I use freeswitch and I would like to block some annoying numbers. So far I tried modify inbound_call.xml like this
<extension name="annoying1">
<condition field="destination_number" expression="^5022xxxx$">
<action application="log" data="NOTICE To jest Rozmowa przych (testowo muzyczka).: ${destination_number}"/>
<action application="answer"/>
<action application="playback" data="/home/mwalko/przywitanie.wav"/>
<action application="hangup"/>
</condition>
</extension>
It doesn't work, should I change this "destination_number"? How can I recognize if for example 5022xxxx calls?
Seems like this "destination_number" points the number which someone called, not the calling one.

destination_number contains the digits entered by the caller, so try out caller_id_number. But keep in mind, that this can be faked.

condition uses regular expressions for matching, so you need to use a dot (.) instead of "x". You can also use something like ^5022\d{4}$

Related

How to define the style of objects in a collection for one record via SLD

How to define the style of objects in a collection for one record via SLD. For example, lines are separate, polygons are separate.
For instance
<Rule>
<ogc:PropertyIsEqualTo>
<ogc:Function name="geometryType">
<ogc:PropertyName>geom</ogc:PropertyName>
</ogc:Function>
<ogc:Literal>GeometryCollection</ogc:Literal>
</ogc:PropertyIsEqualTo>
<PolygonSymbolizer> -- ONLY POLIGON
...
</PolygonSymbolizer>
<LineSymbolizer> -- ONLY LINES
...
</LineSymbolizer>
</Rule>
So far, it turns out that the first style is used for all sub-objects of the recording, and the lines are displayed as polygons.
https://i.stack.imgur.com/RoHBZ.png
A Rule will apply all of its Symbolizers to all features that match its filter, so this SLD is behaving exactly as expected.
You need to have multiple rules with different filters:
<Rule>
<ogc:PropertyIsEqualTo>
<ogc:Function name="geometryType">
<ogc:PropertyName>geom</ogc:PropertyName>
</ogc:Function>
<ogc:Literal>Polygon</ogc:Literal>
</ogc:PropertyIsEqualTo>
<PolygonSymbolizer> -- ONLY POLIGON
...
</PolygonSymbolizer>
</Rule>
<Rule>
<ogc:PropertyIsEqualTo>
<ogc:Function name="geometryType">
<ogc:PropertyName>geom</ogc:PropertyName>
</ogc:Function>
<ogc:Literal>LineString</ogc:Literal>
</ogc:PropertyIsEqualTo>
<LineSymbolizer> -- ONLY LINES
...
</LineSymbolizer>
</Rule>
There are more details in the GeoServer manual, however, none of these techniques will work with a GeometryCollection so you will probably need to rework your data flow to avoid ending up with these.

Not equal xPath query limitations

I need to find logs from EventViewer in Forwarded Events based on computer name, excluding the ones which aren't interesting for me.
My query is like that
*[(System[(Computer!='comp1')]) and
(System[(Computer!='comp2')]) and
(System[(Computer!='comp3')]) and
(System[(Computer!='comp4')]) and
(System[(Computer!='comp5')]) and
(System[(Computer!='comp6')]) and
(System[(Computer!='comp7')]) and
(System[(Computer!='comp8')]) and
(System[(Computer!='comp9')]) and
(System[(Computer!='comp10')]) and
(System[(Computer!='comp11')]) and
(System[(Computer!='comp12')]) and
(System[(Computer!='comp13')]) and
(System[(Computer!='comp14')]) and
(System[(Computer!='comp15')])]
This query works fine unless I add one more condition
and [(Computer!='comp16')])
After that filter stops working and all logs are displayed.
Notice that if I put comp16 instead of comp15 or instead of comp12 everything works fine. So problem is not in the new condition.
The situation is opposite if I use equality filter
(System[(Computer='comp1')]) or
(System[(Computer='comp2')]) or
...
(System[(Computer='comp15')]) or
(System[(Computer='comp16')]) and so on
Filter works fine with much larger queries.
So why not equal operator does not work in large queries?
EDIT
Filter by EventRecordID has the same problem
EDIT 2
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-A5BA-3E3B0328C30D}" />
<EventID>4624</EventID>
<Version>1</Version>
<Level>0</Level>
<Task>12544</Task>
<Opcode>0</Opcode>
<TimeCreated SystemTime="2017-08-18T17:06:15.595105400Z" />
<EventRecordID>1</EventRecordID>
<Correlation />
<Execution ProcessID="584" ThreadID="7100" />
<Channel>Security</Channel>
<Computer>comp1</Computer>
<Security />
</System>
<EventData>
<Data Name="TargetUserName">userName</Data>
<Data Name="TargetDomainName">DOMAIN</Data>
...
<Data Name="ProcessName">-</Data>
<Data Name="IpAddress">-</Data>
<Data Name="IpPort">-</Data>
</EventData>
</Event>
You haven't shown your XML, but it's hard to envisage an XML structure on which this query makes any sense.
Consider the simpler
*[(System[(Computer!='comp1')]) and
(System[(Computer!='comp2')])]
If there is only one System with only one Computer, then this returns true if the Computer is neither 'comp1' nor 'comp2'. But if there is more than one System, or more than one Computer, and if the Computers are not all the same value, then there will inevitably be at least one Computer that is not 'comp1', and at least one that is not 'comp2', and the predicate will therefore always be true.
Usually when people write A!=B in XPath, they should have written not(A=B).

XPath 1.0: Use the attribute value of the current node's parent to find another matching node

I have found many similar posts to this question, but nothing that answers this specific question. I must use XPath 1.0. I do not have XSLT (or XQuery or anything else) available to me, and I cannot use XPath 2.0. I am executing this XPath from inside a piece of software (Arbortext Styler), in which I can use XPath 1.0 to select content from other nodes, but XSLT is not available in this context. Also, I have no control over the structure of the source XML.
When I am in the context of <step>, I need to be able to match a previous procedure/task/step for which that step's parent procedure matches the current procedure's #ref and #seq and has the letter "A" as the value for #conf.
<document>
<topic>
<procedure ref="056" seq="01" conf="A">
<task>
<step>1. Blah Blah (056-01-A)</step>
</task>
</procedure>
<procedure ref="057" seq="02" conf="A">
<task>
<step>2. Blah blah (057-02-A)</step>
</task>
</procedure>
<procedure ref="057" seq="02" conf="B">
<task>
<step>2. Blah blah (057-02-B)</step>
</task>
</procedure>
<procedure ref="057" seq="03" conf="A">
<task>
<step>3. Blah blah (057-02-A)</step>
</task>
</procedure>
</topic>
</document>
What I need is something like this, but without the current() function, which is not supported by the software application:
//procedure[#ref=current()/ancestor::procedure/#ref and #seq=current()/ancestor::procedure/#seq and #conf='A']/task/step
Or something like this, but without the for in return statement:
for $ref in ancestor::procedure/#ref, $seq in ancestor::procedure/#seq return //topic/procedure[#ref=$ref and #seq=$seq and #conf='A']/task/step/text()
Does anyone have any suggestions for how this could be accomplished purely with XPath 1.0? Please note that the position of the procedure cannot be hardcoded. The duplicate refs can occur multiple times and in any position. Also, it is a requirement that this match be done with a starting context of <step>.
I suspect the answer to my question is that it can't be done, but I do know that if it can be done, this is the place to find the answer! Thanks, in advance, to all of you who consider this question.
This post was similar, but the search was looking for children of starting context: Xpath Getting All Nodes that Have an Attribute that Matches Another Node
This was also interesting, but my attribute value is not an ID: Xpath: find an element value from a match of id attribute to id anchor
Any suggestions?
As suggested by both Tomalak and Honza Hejzl, this cannot be done with XPath 1.0. Thanks for the feedback.

Xpath - How to select subnode where sibling-node contains certain text

I want to use XPath to select the sub tree containing the <name>-tag with "ABC" and not the other one from the following xml. Is this possible? And as a minor question, which keywords would I use to find something like that over Google (e.g. for selecting the sub tree by an attribute I would have the terminology for)?
<root>
<operation>
<name>ABC</name>
<description>Description 1</description>
</operation>
<operation>
<name>DEF</name>
<description>Description 2</description>
</operation>
</root>
Use:
/*/operation[name='ABC']
For your second question: I strongly recommend not to rely on online sources (there are some that aren't so good) but to read a good book on XPath.
See some resources listed here:
https://stackoverflow.com/questions/339930/any-good-xslt-tutorial-book-blog-site-online/341589#341589
For your first question, I think a more accurate way to do it would be://operation[./name[text()='ABC']].And according to this , we can also make it://operation[./name[text()[.='ABC']]]

URLRewriteFilter & Break after some rule

greetings all
i have some rules which are very similar
<rule>
<from>/a/**/b/**/c/**/d</from>
<to>/somePlace</to>
</rule>
<rule>
<from>/a/**/b/**/c</from>
<to>/anotherPlace1</to>
</rule>
<rule>
<from>/a/**/b</from>
<to>/anotherPlace2</to>
</rule>
and i want when an exact match occurs for the first rule, it's only executed and the other rules are not, like break in programming, any ideas how to do so ?
Have you tried changing the first rule to instruction to:
<to last="true">/somePlace</to>
If you are using OCPsoft Rewrite URLRewriteFilter, you can achieve this same thing using the Lifecycle control:
.defineRule()
.when(Direction.isInbound().and(Path.matches("/some/{page}/")))
.perform(Forward.to("/new-{page}/"));
If we want to stop processing rules, we can mark the lifecycle as "handled," and no further rules will be processed.
.defineRule()
.when(Direction.isInbound().and(Path.matches("/other/{page}/")))
.perform(Lifecycle.handled());
Subsequently, we can also use the Lifecycle.proceed() or Lifecycle.abort() controls to continue processing even if previously marked handled (in the same rule) or terminate the request completely (aborting the entire HttpServletRequest,) respectively.
the rules are executed in order - if it matches the first rule it will execute it, if it doesnt it will go to the next and so on
therefore you need to order your rules by priority and that should help
paul

Resources