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:

protocol parser driver sql client library
mysql ./lib/libparser3mysql.so (relative path. checkout is impossible) /usr/local/lib/mysql/libmysqlclient.so.15 (506264 Bytes)

DOCUMENT_ROOT: equal with test script directory (comment postprocess method for view)
Ïóòü ê ñêðèïòó: comment postprocess method for view
$response:charset: WINDOWS-1251
$request:charset: WINDOWS-1251
$request:uri: /_test_eng.html
$request:query:
$SQL.connect-string: defined
$MAIL.SMTP: undefined
$CLASS_PATH:
/../data/classes/auth directory exist
/../data/classes/date directory exist
/../data/classes/common directory exist
/../data/classes/sql 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(6+1): 7
^math:random(1000): 617
^math:uuid[]: C6261A8C-076F-4E45-BAB5-39168558A064
^math:uid64[]: 1A5E03C116A82B6B
^math:md5[ñòðîêà]: 4a418b1973f47583cb45652a6f48df45
^math:crypt[ñòðîêà;$apr1$]: $apr1$L4SC0I4f$lclRpxrMiI5K8efN4vY8d/

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 'Ã' char ^str.pos[Ã]: 3
Position '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.base64[]: wOHiw+Tl

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

Manipulations with 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 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

Date manipulations (class $date)

$now[^date::now[]]
Now $now.day/$now.month/$now.year ${now.hour}:${now.minute}:$now.second: 4/2/2012 12:58:57
Print now in sql format ^now.sql-string[]: 2012-02-04 12:58:57
Print now in UNIX timestamp format: 1328345937
Roll date to 5 days ahead ^now.roll[day](-5): 30/1/2012
Roll date to 30 days behind ^now.roll[day](30): 29/2/2012

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: 4/2/2012
adate: 4/2/2012
mdate: 4/2/2012

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

Working with class $hashfile

Create object: $hf [$hf[^hashfile::open[_test]]]: object was created sucessfully

Number of records: 79
Adding record (48CD74DF-D176-48E3-B909-19668C68A5CB) for 3 days:
$hf.[48CD74DF-D176-48E3-B909-19668C68A5CB][
   $.value[439740851]
   $.expires(3)
]
Priint hashfile content (max 5 records):
D7B3F0C4-4FD9-40B1-AA7D-E2EBE6B5D486=2
7FBA01E5-707F-465D-9AAE-C9A0170A330D=1
EC4E7BF9-5CA2-4219-98FC-8ACC2932586D=5
3F1542FE-E3AA-44C4-BE78-48F3126FD5E5=2
479CB7DD-F255-448F-AD25-D0ED4D4A58C4=642993129

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/1.0 (+http://www.commoncrawl.org/bot.html) Browser USER_AGENT string
HTTP_X_FORWARDED_FOR
Filled if visitor come through proxy server
REMOTE_HOST

REMOTE_ADDR 38.107.179.220 Visitors' IP address
PARSER_VERSION 3.4.1 (compiled on amd64-unknown-freebsd8.2) 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="WINDOWS-1251" ?>
<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 0.013216 0.020896 0.024452
$status:rusage.stime (secs) time for reading files 0.004407 0.005224 0.005224
$status:rusage.maxrss (blocks) memory, used by process 6444 7992 8200
$status:memory.used (KB) user 2436 2716 2512
$status:memory.free (KB) free (fragmentated) 248 864 1068
$status:memory.ever_allocated_since_compact (KB) allocated since last garbage collection 3106.57 3479.93 1.03125
$status:memory.ever_allocated_since_start (KB) allocated since start 3106.57 3479.93 3482.05