Parser 3.x test page

If you see this page, you have sucessfully installed Parser and trying to test it.

To see full paths to configuration files and DOCUMENT_ROOT comment out postprocess[] method.

If something is marked as red, then something is configured the wrong way or automatic detection is impossible (related to library files and codepages search with relative paths).


Global variables defined in config auto.p

$CHARSETS:

koi8-r $charsetsdir/koi8-r.cfg (5104 Bytes)
windows-1251 $charsetsdir/windows-1251.cfg (5128 Bytes)

$SQL:

$SQL.drivers. Wrond data structure.
Probably TABs characters was replaced by spaces characters while manual editing configuration auto.p
Table content:
string protocWoldriverclient
1 mysql../cgi/lib/libparser3mysql.so/usr/local/lib/mysql/libmysqlclient.so

DOCUMENT_ROOT: undefined
: comment postprocess method for view
$response:charset: WINDOWS-1251
$request:charset: UTF-8
$request:uri: /_test_eng.html
$request:query:
$SQL.connect-string: defined
$MAIL.SMTP: undefined
$CLASS_PATH:
/../data/classes/sql directory exist
/../data/classes/auth directory exist
/../data/classes/io directory exist
/../data/classes/utils directory exist
/../data/classes/engine directory exist
/../data/classes directory exist

Parser demo

Manipulations with cookie (class $cookie)

Read $cookie:test: undefined
Write to cookie value ABC $cookie:test[ABC] (press Reload)

Math operations (class $math)

^eval(8+6): 14
^math:random(1000): 73
^math:log(1000): 6.90775527898214
^math:log10(1000): 3
^math:uuid[]: 30D75054-BC5A-4E48-8094-083DD5B5BD14
^math:uid64[]: B6FB47A00D6C698A
^math:md5[StRiNg]: ed4577017f40ccb66fcf09dda2fe2a3c
^math:crypt[StRiNg;$apr1$]: $apr1$lTZlJt.O$xsMX/GwwbDA9M5lnHQVxU1
^math:crc32[StRiNg]: -1398522877

Strings manipulations (class $string)

Definition $str[]
String length ^str.length[]: 6
Uppercase string ^str.upper[]:
Lowercase string ^str.lower[]:
First 2 chars ^str.left(2):
Last 3 chars ^str.right(3):
Substring ^str.mid(1;3):
Position of '' char ^str.pos[]: 1
Position of '' char starting from position 2 ^str.pos[](2): -1
Position of 'X' char ^str.pos[X]: -1
Replacement substring '' to XX using match ^str.match[][]{XX}: XX
Replacement chars '' to 'Y', '' to 'Z' using ^str.replace[$repl]: YZ
^str.trim[both;]:
^str.trim[start;]:
^str.trim[end;]:
^str.trim[left;]:
^str.trim[right;]:
^str.base64[]: 0JDQsdCy0JPQtNC1
^str.js-escape[]: %u0410%u0431%u0432%u0413%u0434%u0435
^str:js-unescape[%u0410%u0431%u0432%u0413%u0434%u0435]:

Working with class $inet

^inet:aton[10.0.0.2]: 167772162
^inet:aton[192.168.1.5]: 3232235781
^inet:ntoa(167772162): 10.0.0.2
^inet:ntoa(3232235781): 192.168.1.5

Form values manipulations (class $form)

$form:a: undefined
Safe conversion $form:a to integer: ^form:a.int(1): 1
$form:b undefined
$form:qtail: undefined
click here to check reading form values

Manipulations with hash (class $hash)

$hash1[
  $.a[1]
  $.b[2]
  $.c[3]
]
^hash1.foreach[key;value]{
  $key=$value
}[<br />]
a=1
b=2
c=3

Checking item with key 'a' (^hash1.contains[a]): item with key 'a' exist

Manipulations with table (class $table)

$tbl1[^table::create{name	col1	col2
Vasya	3	5
Dima	4	14}]
$tbl1 rows quantity: 2
$tbl1 columns quantity: 3
Print columns:
string column
1 name
2 col1
3 col2

Print content $tbl1:
string namecol1col2
1 Vasya35
2 Dima414

$tbl2[^table::create{name	col1	col2
Vova	3	44}]
$tbl2 rows quantity: 1

join $tbl1 to $tbl2 [^tbl2.join[$tbl1]]
$tbl2 rows quantity ^tbl2.count[]: 3
Print table:
string namecol1col2
1 Vova344
2 Vasya35
3 Dima414

select table rows where col1 values are equal 3: ^tbl2.select($tbl2.col1 == 3)
string namecol1col2
1 Vova344
2 Vasya35

Making hash with tables (where hash keys are col1 values): $hData[^tbl2.hash[col1][$.distinct[tables]]]

Print hash data:
Key Value
3
string namecol1col2
1 Vova344
2 Vasya35
4
string namecol1col2
1 Dima414

Making hash with strings (where hash keys are col2 values and values are name values): $hData[^tbl2.hash[col2;name][$.type[string]]]

Print hash data:
Key Value
44 Vova
5 Vasya
14 Dima

Date manipulations (class $date)

$now[^date::now[]]
$now.day/$now.month/$now.year ${now.hour}:${now.minute}:$now.second: 19/1/2021 23:48:51
$now.week: 3
$now.weekyear: 2021
Print now in sql format ^now.sql-string[]: 2021-01-19 23:48:51
Print now in UNIX timestamp format ^now.unix-timestamp[]: 1611089331
Print now in GMT format ^now.gmt-string[]: Tue, 19 Jan 2021 20:48:51 GMT
Number of last day in current month ^now.last-day[]: 31
Roll date to 5 days ahead ^now.roll[day](-5): 14/1/2021
Roll date to 30 days behind ^now.roll[day](30): 13/2/2021

Manipulations with files (class $file)

Write table $tbl1 to file _test.cfg (^tbl1.save[_test.cfg]): File created successfully
^file:dirname[/_test.cfg]: /
^file:basename[/_test.cfg]: _test.cfg
^file:justname[/_test.cfg]: _test
^file:justext[/_test.cfg]: cfg

Get saved file information $fstat[^file::stat[_test.cfg]]:
File size [$fstat.size]: 35
cdate: 19/1/2021
adate: 19/1/2021
mdate: 19/1/2021

Loading data into $tbl3 from file DOCUMENT_ROOT/_test.cfg and out table content ($tbl3[^table::load[_test.cfg]]):
string namecol1col2
1 Vasya35
2 Dima414

File copy (^file:copy[_test.cfg;_copy.cfg]): ok

File delete (^file:delete[_test.cfg]): ok

Working with class $hashfile

Create object: $hf [$hf[^hashfile::open[_test]]]: object was created sucessfully
Number of records: 32
Adding record (4C44157C-ADA2-47CF-A329-522335BC6D11) for 3 days:

$hf.[4C44157C-ADA2-47CF-A329-522335BC6D11][
   $.value[809772297]
   $.expires(3)
]
Cleanup hashfile from expired records (^hf.cleanup[]): ok

Print hashfile content (max 5 records):
782F4024-68E2-45E9-B2D4-F6424B48E367=194041783
5BD61690-EF91-4684-A9A3-E03D4FE2E994=462556526
3DF38E9B-D5A7-4501-B257-6981465C5E66=1
D5A78407-5723-4A4B-9E4C-97C73AC7C713=7
B3E9780A-299A-415C-A178-2CDB22C3DEB9=3

Close hashfile files and release locks (^hf.release[]): ok

Manipulations with enviroment variables (class $env)

Variable Value Comment
SERVER_NAME www.parser.ru DNS Server name
QUERY_STRING
For get values use $form class
HTTP_REFERER

HTTP_USER_AGENT CCBot/2.0 (https://commoncrawl.org/faq/) Browser USER_AGENT string
HTTP_X_FORWARDED_FOR
Filled if visitor come through proxy server
REMOTE_HOST

REMOTE_ADDR 195.218.200.16 Visitors' IP address
PARSER_VERSION 3.4.6rc (compiled on amd64-unknown-freebsd11.4) Parser3 version (if not defined - parser3 before 3.1.5)

Working with SQL

^int:sql{SELECT 2+2}: 4

Manipulations with XML

Create xdoc:

$document[^xdoc::create{<?xml version="1.0" encoding="UTF-8" ?>
<document>
	<t attr="Hello" n="123"/>
	<t attr="Bye" n="234" n2="xxx"/>
	<text>Text</text>
</document>}]
Object xdoc created successfully.
Get <t /> elements $elements[^document.select[//t]] :
<t /> elements quantity: 2
Print elements using foreach:
name: 't', type: '1', attributes quantity: '2', attributes: attr='Hello', n='123'
name: 't', type: '1', attributes quantity: '3', attributes: attr='Bye', n='234', n2='xxx'

Working with classes Status and Memory

Field Description Value
on start now after ^memory:compact[]
$status:rusage.utime (secs) process time 208.034316 208.040695 208.136839
$status:rusage.stime (secs) time for reading files 386.381965 386.381965 386.383764
$status:rusage.maxrss (blocks) memory, used by process 601160 601160 601160
$status:memory.used (KB) user 173376 173624 68924
$status:memory.free (KB) free (fragmentated) 394112 393864 454988
$status:memory.ever_allocated_since_compact (KB) allocated since last garbage collection 184676.5 185003.34375 7.59375
$status:memory.ever_allocated_since_start (KB) allocated since start 14157002.609375 14157329.453125 14157337.046875