rejetto forum

introducing {.var domain.}

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
it may be not easy to understand why i recently introduced this new command.
i'll explain shortly, for those who are interested.

example:
you want to show an information related to the country of your visitor, like the flag.
you need to retrieve the "country" information via an external web service.
Months ago i posted this example
Code: [Select]
[request]
{.add to log|COUNTRY IS {.cache|#countries|%ip%|{:{.trim|
{.substring|Country: |City|{.load|http://api.hostip.info/get_html.php?ip=%ip%&position=true.}|include=none.}
.}:}/cache.}.}

[start]
{.load|country.cache|var=#countries.}

[quit]
{.save|country.cache|var=#countries.}

Since the web service is slow, we don't want to use it everytime the same IP is worked.
At the time i introduced this new command {.cache.}, working with variables with "table" format, that easily solves the problem, by loading the value only if it was not already done.

It's ok, but it's a pity that {.cache.} works only on table variables, while it may be useful with simple variables.
Truth is, in this language you don't necessarily have to use "tables" to have multiple values.
You can have many variables, named #country.for.ip.131.23.51.3
and #country.for.ip.150.4.66.22
etc etc
all of them starting with the same name.

This way, the command "cache" would have worked this way
{.cache|#country.for.ip.%ip%|{: ...web service... :}.}

it's mostly the same, but it's ready to work on single values instead of multiple ones.
that's it, we can create as many variables as we want, without worrying.
this way we can design our scripts/commands to work on simple variables, that's more generic use than tables.

indeed, i mean to change the {.cache.} command in the near future, to work on simple variables instead of tables.

in the same script i suggested to load/save all collected values, to make them persistent.
that's where the {.var domain.} command comes to help.
you need tools to work with multiple variables, that have similar names, to know who they are, and what's their value.
Maybe this is not enough for every need, but i will add stuff as i see the need for it.


Offline Oxyandy

  • Occasional poster
  • *
    • Posts: 27
    • View Profile
Hi rejetto,
I am making use of this, it really helps me identify Users timezones, locations etc..
But hey, it is a 3 year old post  ::)
Do you have any news ?
You mention making changes, but have seen nothing posted elsewhere. ?
So in that time has the technique evolved ?

The database, does seems very incomplete - could I use something else a Geo-IP offline database for example..
I have been reading & soaking up heaps of info across the forums.
I will look deeper into how this works 'as is' as my knowledge grows, just thought I would ask first.

Thanks

[SOLVED]
Working very nicely to create a structured custom log, using different database
Server scripts working great, combined with local scripts create a clean log, with only what I want
even making use of {.if not| to exclude g-bot

DATE - TIME - IP - COUNTRY - STATE - CITY - LOCAL_TIME - FILE - REFERER
« Last Edit: June 03, 2013, 04:17:24 PM by Oxyandy »