rejetto forum

Server Side Scripts [request] - Nesting

Oxyandy · 17 · 9148

0 Members and 1 Guest are viewing this topic.

Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
[+request]
{.if not|{.pos|one|{.header|one.}.}|
{.if not|{.pos|two|{.header|two.}.}|
{.if not|{.pos|three|{.header|three.}.}|
{.if not|{.pos|four|{.header|four.}.}|
{:{.disconnect.}:}
.}.}.}.}

Any combination of 2 of the above works, but not 3 or 4 of them, limitation or am I doing it wrong ?

In windows batch, would be something like this

If %%a NEQ Google (
If %%b NEQ 192.168.1.1 (
If %%c NEQ rejetto (
If %%d NEQ patch (
echo Sorry if you made it here, you do not belong !
))))
« Last Edit: June 06, 2013, 12:40:28 AM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Thanks for the replies  :-X
I have it all worked out now.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2023
    • View Profile
select what you need   AND or OR syntax
Code: [Select]
[+request]
{.if not|{.or|{.pos|one|{.header|one.}.}
                 |{.pos|two|{.header|two.}.}
                 |{.pos|three|{.header|three.}.} 
                 |{.pos|four|{.header|four.}.}
            /or.}
          |{:{.disconnect.}:}
.}

or

Code: [Select]
[+request]
{.if not|{.and|{.pos|one|{.header|one.}.}
                 |{.pos|two|{.header|two.}.}
                 |{.pos|three|{.header|three.}.}
                 |{.pos|four|{.header|four.}.}
            /and.}
          |{:{.disconnect.}:}
.}

 if A then if B then if C then ACTION
-->>  {.if|{.and|A|B|C.}|ACTION.}
 

« Last Edit: June 04, 2013, 01:33:20 PM by Mars »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Hi Mars,
You should close those examples
[+request]
{.if not|
      {.or
            |{.pos|one|{.header|one.}.}
            |{.pos|two|{.header|two.}.}
            |{.pos|three|{.header|three.}.} 
            |{.pos|four|{.header|four.}.}
       /or.}
|{:{.disconnect.}:}
.}


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2023
    • View Profile
 you are right ;)
« Last Edit: June 04, 2013, 01:33:51 PM by Mars »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Going another level deeper

[+request]
{.if|
      {.or
            |{.pos|one|{.header|one.}.}
            |{.pos|two|{.header|two.}.}
            |{.pos|three|{.header|three.}.}
            |{.pos|four|{.header|four.}.} <-- {.or One or more of these 4=Yes ?... (With {.and ALL of these 4=Yes?)
       /or.}
|{.if not|
            {.match|this;this;or_this|%IN_THIS%.} <-- but none of these 3=Yes in IN_THIS ?
|{:{.exec|OK then ! DO THIS !.}:}
.}
.}

Now Mars, I did this for others because it has been really hard to find good examples of script snippets,
so go on & tell me if it's wrong  ::)
« Last Edit: June 04, 2013, 06:28:32 PM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Help Question
[+request]
{.set|agent|{.header|User-Agent.}.}

How do I check if it is Null ? if %agent% = ""

I am getting triggers to my rules from null results, which I want to block. (Such as port scans.)
Trial & Error is getting tiresome  :'(
Thanks very much !

EDIT:
So it can be added to the rules like this -- {.match|NULL|{.^agent.}.}
How do I do this ?

EDIT2:
Ok, I thought of a 'work around' define NULL with something that could never exist,
LIKE SO = NULL could never exist in the header, lol
[+request]
{.set|NULL|{.header|NULL.}.}

SO, {.^NULL.} must always be "" (null) - must be an easier way, (waiting for a reply) but at least my learning can move forward !

{.match|{.^NULL.}|{.^agent.}.} <- half right, has one major flaw, do you know ?  ;D
Gives me the condition if no User-Agent <- ^umm not exactly {whistle}
« Last Edit: June 06, 2013, 12:43:19 AM by Oxyandy »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2023
    • View Profile
%IN_THIS%   -->  http://www.rejetto.com/wiki/index.php?title=HFS:_Template_symbols

{.match|this;this;or_this|%IN_THIS%.}  --> http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands

match | A | B
    it is true if the content B is matched by the mask A.




{.match|this1;this2;this3|%IN_THIS%.} <-- but none of these 3=Yes in IN_THIS ?

--> {.or|{.match|this1|%IN_THIS%.}|{.match|this1|%IN_THIS%.}|{.match|this1|%IN_THIS%.}.}


[+request]
{.if|{.or
            |{.pos|one|{.header|one.}.}
            |{.pos|two|{.header|two.}.}
            |{.pos|three|{.header|three.}.}
            |{.pos|four|{.header|four.}.}
       /or.}
    |{:{.if not|
               {.or
                     |{.match|this1|%IN_THIS%.}
                     |{.match|this1|%IN_THIS%.}
                     |{.match|this1|%IN_THIS%.}
                /or.}
               |{:{.exec|OK then ! DO THIS !.}:}
      .}:}
.}



Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2023
    • View Profile
Gives me the condition if no User-Agent

 --> {.if not|{.header|User-Agent.}| OK there is User-Agent.}

{.header|User-Agent.} return the content of User-Agent, if this last one is not set then {.header|  .}  give an empty string  -->  {.if not| .}  return TRUE in this case


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Nope I didn't want an answer to this, I needed help with NULL (Just read your reply -Thank You !)
Mars it seems you are doing it the hard way..
Below these 2 are EXACTLY SAME - they both work  8)
The top example is useful if you have - %IN_THIS_1%, %IN_THIS_2%,,,,,,,etc
Code: [Select]
[+request]
{.if|{.or
            |{.pos|one|{.header|one.}.}
            |{.pos|two|{.header|two.}.}
            |{.pos|three|{.header|three.}.}
            |{.pos|four|{.header|four.}.}
       /or.}
    |{:{.if not|
               {.or
                     |{.match|this1|%IN_THIS%.}
                     |{.match|this2|%IN_THIS%.}
                     |{.match|this3|%IN_THIS%.}
                /or.}
               |{:{.exec|OK then ! DO THIS !.}:}
      .}:}
.}
Code: [Select]
[+request]
{.if|{.or
            |{.pos|one|{.header|one.}.}
            |{.pos|two|{.header|two.}.}
            |{.pos|three|{.header|three.}.}
            |{.pos|four|{.header|four.}.}
       /or.}
    |{:{.if not|
            {.match|this1;this2;this3|%IN_THIS%.}
            |{:{.exec|OK then ! DO THIS !.}:}
      .}:}
.}

A real example is this
      {.match|192.168.1.1;192.168.1.104;127.0.0.1|%ip%.}

So I use this to ignore requests from my PC
« Last Edit: June 06, 2013, 12:49:49 AM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Please Mars, help - lol
I just don't seem to be getting this right :o
Let's use a real example of NULL

Code: [Select]
{.comment| IF REFERER NEQ NULL - ADD REFERER to HFS INTERNAL LOG.}
[+request]
if Referer is NOT NULL
|{.add to log|Came From {.header|Referer.}
.}

I chose {.header|Referer.} because it's easy to test :)

EDIT: Gee, I was right in theory, but wrong in usage (syntax)..
Took a bit of work to stumble upon the 'right' usage, too.
So maybe these posts of mine maybe save some people a bit of time :)
« Last Edit: June 05, 2013, 12:07:45 PM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Ok, based I what I said earlier, this WORKS
No Referer ?, no log entry.
Referer exists ?, log entry is made.

Code: [Select]
{.comment| IF REFERER NEQ NULL - ADD REFERER to HFS INTERNAL LOG.}
[+request]
{.if not|{.match|{.^from.}|{.^NULL.}.}|{:{.add to log|Came From {.^from.}.}:}.}

So unless someone can show me a simpler way, I will stick to this :)
« Last Edit: June 06, 2013, 12:35:51 AM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Next, to able to make a log of 404 requests..
Haven't given this much thought yet, very happy to see any existing ideas..

Off to read a bit
« Last Edit: June 06, 2013, 12:25:54 AM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Ok,
1. I am tired, have been reading for about a week.
2. I am stuck.
How do I get 404's to a string in Events ?

Can someone tell me please, if this is possible ?
I have a program which accesses files on the server, and if they are 404, then maybe they shouldn't be.
So a 404 log is very important..
I have ideas, but it keeps getting complex :(

Thanks !

EDIT_1
This is a shame
         |{.exists|file:///Z:%url%.}
Wont work

Shorten folder path from URL to just filename ?
/Some_Path/Some_File.ext   =  %url%
to just
Some_File.ext
Cause then I could use {.exists|Z:\Some_Path\Some_File.ext.}

« Last Edit: June 06, 2013, 10:03:17 AM by Oxyandy »


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
[SOLVED] Well finally...

I added a Header String into my program, from that in [request] I can

{.set|Header_String|{.header|My_Custom_Header_String.}.}


Then from that, I can manipulate the Output - in many different ways.
Including

{.exists|Z:\Some_Path\{.^Header_String.}.} = Is file 404 ?


### Sure there was probably an easier way,
but no amount of searching/reading/requesting help/advise could give me an answer to my question.

How do I get 404's to a string in Events ?

 
« Last Edit: June 09, 2013, 03:18:35 AM by Oxyandy »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
Code: [Select]
if Referer is NOT NULL
|{.add to log|Came From {.header|Referer.}
.}

{.if not|{.header|referer.}|{:
  {.add to log|ciao.}
:}.}


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
sorry for the late reply

I added a Header String into my program, from that in [request] I can
{.set|Header_String|{.header|My_Custom_Header_String.}.}

Then from that, I can manipulate the Output - in many different ways.
Including
{.exists|Z:\Some_Path\{.^Header_String.}.} = Is file 404 ?

what you get by passing by the "header_string" variable?

you can {.exists|Z:\Some_Path\{.header|My_Custom_Header_String.}.}

How do I get 404's to a string in Events ?

i don't understand what you mean