Home
WebX Guide - Dimitri (dim) Tools HOMEPAGE
Contents
1. 0 lt error gt Cannot open ls command FILE SIZE OWNER lt while gt lt fgets gt pp buff 200 sst lt if gt sst 0 lt break gt lt if gt word buff 1 like d lt fputs gt stdout word buff 9 word buff 5 word buff 3 lt end gt lt pclose gt pp trim NAME function to drop insignificant spaces in the NAME value Examples Title Title gt Hello Mister Dr Brown trim Title trim Title gt Hello Mister Dr Brown crypt NAME_val NAME_ passwd function to crypt uncrypt any value by password Examples lt passwd gt Very secret password Value value is crypted to crypt value passwd lt value gt crypt value passwd Crypted Value value is uncrypted to crypt value passwd lt cookie gt Login lt if gt exist home crypt Login passwd welcome html lt error gt Wrong User Name lt end gt lt include gt home crypt Login passwd welcome html txt2url NAME url2txt NAME functions to convert text to URL format and back Examples Title Title gt Story of L Oreal URL Title txt2url Title gt Story 200f 20L 270real so the correct URL is lt a href cgi bin WebX x search Title txt2url Link gt Title lt a gt In Line Values and Functions 14 WebX Guide uppercase NAME lowercase NAME functions to convert text to upper lower case Examples
2. lt WebXcommand gt lt if gt condition lt end gt lt if gt condition lt else gt lt end gt Action no comments Conditions icmp X op Y integer comparison between X and Y cmp X op Y string comparison between X and Y X op Y string comparison between X and Y X Y Values Op gt lt gt lt like like for like you can use any pattern as a z fmt NAME format check format of NAME value format int check for integer float check for float filled NAME check variable NAME exists and filled exist Filename check than file Filename exist EOF check if EOF reached during database search Note icmp cmp filled EOF script fmt exist can be used for NOT conditions Examples lt if gt number 0 lt number gt 100 lt if gt icmp count lt 0 lt count gt 0 lt if gt filled Name lt Name gt UNKNOWN lt Profile gt lt end gt lt if gt Name ADMIN lt h1 gt Welcome to the Administration Service lt h1 gt lt call gt welcome lt else gt lt h1 gt Access Forbidden lt h1 gt lt end gt WebX Guide QUIT Syntax lt quit gt Action stop WebX execution Examples lt if gt MAX 1000 lt h1 gt Reached MAX value lt h1 gt lt quit gt lt end gt ERROR Syntax lt error gt message Action stop WebX execution with Error Message This action will
3. lt continue gt lt replace gt buff Windows UNIX lt fputs gt fpOUT buff n sst lt end gt lt fclose gt fpOUT lt fclose gt fpIN REPLACE 10 WebX Guide PROCESS I O Syntax lt popen gt ppID Command mode state open a process stdin stdout lt fgets gt ppID ValName size state read a line from process stdout lt fputs gt ppID Value state write a line to process stdin lt pclose gt ppID state close an opened process Action Process I O interface ppID any unique name uses to name file descriptor mode any legal popen 3C value w or r state name of value where will be stored the operation status Examples lt popen gt pp Is 1 r sst lt if gt sst 0 lt error gt Cannot open Is command FILE SIZE OWNER lt while gt lt fgets gt pp buff 200 sst lt if gt sst 0 lt break gt lt if gt word buff 1 like d lt fputs gt stdout word buff 9 word buff 5 word buff 3 lt end gt lt pclose gt pp SLEEP Syntax lt sleep gt sec Action suspend execution for a number of seconds sleep Examples tail of the file filename mogn lt fopen gt fp filename r sst lt if gt sst 0 lt error gt Cannot open file filename lt while gt lt fgets gt fp buff 300 sst lt if gt sst 0 lt sleep gt 1 lt continue gt lt
4. database Let show some examples with SQL queries SELECT SELECT simple lt X_BASE gt dim lt X_USER gt dim lt X_PASSWD gt WebX lt skip first 10 records and show next 40 gt Database Interface 17 WebX Guide lt table border 3 gt lt tr gt lt th gt No lt th gt lt th gt Author lt th gt lt th gt Title lt th gt lt th gt Year lt th gt lt tr gt lt no gt 0 lt sqI gt select author title year from book order by year lt no gt lt if gt icmp no lt 10 lt continue gt lt if gt icmp no gt 50 lt break gt lt tr gt lt td align right gt no lt td gt lt td gt author lt td gt lt td gt title lt td gt lt td gt year lt td gt lt tr gt lt end gt lt table gt SELECT Recursive lt Print a tree from book_catalogue table parent ref name print_date Note parent amp ref makes the father son relation Like 0 1 INFORMIX User Manual 1996 09 17 1 2 Part I 1996 09 17 2 3 SQL intro 1996 09 17 1 4 Part II 1996 09 17 1 5 Part HII 1996 09 17 0 6 INFORMIX Administration 1996 09 17 gt lt function gt PrintTree parentID lt ul gt lt sql gt select from book_catalogue where parent parentID lt li gt lt i gt name lt i gt Modified print_date lt call gt PrintTree parent
5. invoke the Error Page execution the name of this page is stored in the reserved variable X_ERROR default value x error The contents of this page is free the error message can be shown as X_ERRMSG value If the X_ERROR is not set default format will be used Examples lt if gt fmt MAX int lt error gt Invalid MAX value lt if gt fmt AGE int lt error gt Invalid AGE value Example of x error lt h1 gt ERROR lt h1 gt lt hr gt lt h3 gt During execution the follow error has been occurred lt h3 gt lt br gt lt i gt X_ERRMSG lt i gt lt br gt lt hr gt WHILE Syntax lt while gt condition lt break gt lt continue gt lt end gt Action making a loop Conditions lt while gt unlimited loop till lt break gt or lt quit gt lt while gt values NAME loop for all values of multi value NAME lt while gt words NAME loop for all words from NAME value separated by SPACE lt while gt words NAME SEP loop for all words in NAME value separated by any symbols from string SEP QUIT WebX Guide Note during a loop for values or words the NAME value will keep one of values or words at time Examples WHILE Unlimited loop lt State gt Ok lt while gt lt if State Ok lt break gt lt end gt WHILE Multivalues INPUT FORM lt form action cgi bin WebX method POST gt lt b gt City included for search lt b g
6. lt if gt uppercase City PARIS lt call gt parisLINE lt call gt lowercase City LINE n r t the reserved values to print the lt NL gt lt CR gt lt Tab gt Examples Result t number t score n lt replace gt String t lt replace gt Text n lt br gt Text sh NAME function to escape shell command from the NAME value security reasons Examples if Name is nobody cd rm rf sh Name is nobody cd A rm rf lt shell gt bin script login sh Name 2 gt amp 1 int format VALUE function to present integer value decimal as output of C function printf Examples lt Numb gt 100 Numb 05d int 05d Numb lt br gt Numb 050 int 050 Numb lt br gt Numb 05h int 05h Numb lt br gt expr VALUES expression function to calculate arithmetical expression Examples lt A gt 1 lt while gt lt TOTAL gt expr TOTAL X Y lt A gt lt if gt icmp A gt 5 lt break gt lt end gt Note expr 20 3 gt 6 expr 20 0 3 gt 6 66666 In Line Values and Functions 15 WebX Guide X_ERRMSG reserved variable with the last WebX error message Examples lt if gt X_SQLCODE 0 lt h1 gt Database Error Message X_ERRMSG lt h1 gt lt quit gt lt end gt X_ROOT reserved variable keeps the WebX root dire
7. query gt select from News where TIMESTAMP between X_DT 360 and X_DT dt2str Name Format str2dt Name Format internal functions to convert UNIX time to string and back Format can be represented by any character pattern contains DD MM HH etc Examples Now is dt2str X_DT hh mi ss dd mm yyyy lt fputs gt stdout Enter date format lt fgets gt stdin Format 100 lt fputs gt stdout Enter date lt fgets gt stdin Date 100 lt query gt update News set TIESTAMP str2dt Date Format cut len NAME function to cut the value of NAME variable to len characters it can protect your code if at place of 10 letters user sends to you 10 000 Examples lt Name gt cut 20 Name lt Address gt cut 60 Address len NAME function to give the length of the NAME value Examples lt if gt icmp len Name gt 20 WARNING The entered Name is longer than 20 characters so it ll be truncated lt br gt lt end gt lt Name gt cut 20 Name str begin end NAME function to get the substring from the NAME value Examples In Line Values and Functions 13 WebX Guide lt fgets gt fp buff 200 sst lt query gt insert into address Street No City values str 1 40 buff str 41 45 buff str 46 60 buff word NAME no function to get the word number no from the NAME value Examples lt popen gt pp Is 1 r sst lt if gt sst
8. Preface Installation First View Standard WebX commands SET INCLUDE SHELL IF QUIT ERROR WHILE UNLINK FILE COOKIE FUNCTION amp CALL WebX Guide WebX User s Guide dim v 2 0 April 1999 WebX Guide REPLACE FILE VO PROCESS I O COMMENTS In Line Values and Functions Database interface Other features Preface This software I ve developed for my personal pleasure It s a compilation of some my ideas which I wanted to see realized and used in Dynamic Web and Data Base developing The goal of this product is to make our life more easy I say it every time when I develop something but is it true for WebX it s up to you So I always wanted to have a kind of program which can be started with same interfaces on my Web server browser and on my screen in shell mode Second I want to avoid any problems with design and result presentation of this program The most simple and popular language today is HTML and it s always more sample in idea to add several dynamic commands into existing page than to put the whole page description into the program code That s why I ve decided to write a program capable to add an HTML extension into already existing or completely new pages to have more softness in development And today you can find a lot of product with the same idea and sometimes doing the same thing So what is different REALIZATION I propose you my realization which is started
9. bX Guide numb 2 call Power2 numb numb call Fact numb Old values A A B B C C lt call gt Reset A B C New values A A B B C C REPLACE Syntax lt replace gt Name OldString NewString Action replace all parts of the old text by the new one in the Name value Examples mn lt replace gt Name lt replace gt Address mn onn lt query gt insert into Client Name Address values Name Address lt replace gt Country FR France FILE I O Syntax lt fopen gt fpID Filename mode state open a file lt fgets gt fpID ValName size state read a line from file lt fputs gt fpID Value state write a line to file lt fclose gt fpID state close an opened file Action File I O interface fpID any unique name uses to name file descriptor stdin stdout and stderr are reserved names for std I O mode any legal fopen 3C value w r a etc state name of value where will be stored the operation status Examples won lt fopen gt fpIN input txt r sst lt if gt sst 0 lt error gt Cannot open input file lt fopen gt fpOUT outputFilename w sst lt if gt sst 0 lt error gt Cannot open output file outputFilename lt while gt lt fgets gt fpIN buff 200 sst lt if gt sst 0 lt break gt lt if gt buff like Comment
10. bX output from the lt file gt to the lt end gt to the file named Filename Examples lt unlink gt tmp page No lt file gt tmp page No lt end gt lt include gt tmp page No lt unlink gt tmp page No COOKIE Syntax lt cookie gt Name UNLINK WebX Guide Action get the Netscape Cookie value to the WebX variable with the same name Note the feature of the setting a cookie value is inactivated for the moment Examples lt html gt lt cookie gt USER_ID lt if gt filled USER_ID lt include gt login html lt quit gt lt end gt lt include gt welcome USER_ID html lt html gt FUNCTION amp CALL Syntax lt function gt FunctionName lt return gt lt return gt value lt end gt lt function gt FunctionName parameters lt end gt lt call gt FunctionName lt call gt FunctionName parameters call FunctionName call FunctionName parameters Action function using Note function can be recursive Examples lt function gt Power2 val lt return gt expr val val lt end gt lt function gt Fact val lt if gt val 1 lt return gt 1 lt return gt expr val call Fact expr val 1 lt end gt lt function gt Reset v1 v2 v3 lt set gt v1 0 lt set gt v2 1 lt set gt v3 2 lt end gt FUNCTION amp CALL We
11. ctory name for the current config Examples lt include gt X_ROOT Lib x draw DIR reserved variable keeps the WebX current directory name Examples lt include gt DIR init html lt shell gt DIR bin checkuser Login lt chdir gt DIR X_PID reserved variable keeps the WebX process id pid Examples lt file gt tmp out X_PID X_PROG reserved variable keeps the WebX process name Examples lt if gt X_PROG like IFX lt X_BASE gt informix lt if gt X_PROG like ORA lt X_BASE gt oracle env NAME function to take the environment value Examples PATH env PATH lt br gt SCRIPT_NAME env SCRIPT_NAME lt br gt USER env REMOTE_USER lt br gt Called URL env HTTP_REFERER lt br gt 16 WebX Guide Database Interface It s very easy First before you run any database queries you need to give values for follows variables X_BASE database name if you don t use the default database name X_USER and X_PASSWD connection user name and password if you don t use the default login connection For the immediate execution query you can use lt sglexec gt SQLquery For the query which return some values you can use lt sql gt SQLquery lt break gt lt continue gt lt end gt Note in the second case any query may be executed even for immediate execution so if you know nothing about nature of your query user inpu
12. end gt buff lt end gt CHDIR Syntax PROCESS I O WebX Guide lt chdir gt directory Action change the current directory Note when WebX started the current directory is changed to the root directory for the current config see x config Examples lt chdir gt DIR lt file gt output txt lt end gt COMPILE Syntax lt compile gt ON OFF Action set on off value translation default ON Examples lt name gt Unknown name gt Unknown lt compile gt OFF name gt name HTML Syntax lt html gt ON OFF Action set on off translation accentuated letters to the HTML equivalents default ON Examples lt name gt H l ne name gt H amp acute l amp egrave ne lt html gt OFF name gt H l ne COMMENTS Syntax lt Any text gt Action put some comments Examples lt Follow lines are comments and next command will never work lt shell gt rm rf but it s very dangerous to put it after end of comments gt COMPILE 12 WebX Guide In Line Values and Functions today reserved variable with the current date in format YY YY MM DD Examples Today is today lt set gt query select from News where NEWS_DATE today X_DT reserved variable with the current datetime in seconds since 1970 UNIX time Examples Last news for the last hour lt
13. from shell WebX without db connections WebX IFX to communicate with INFORMIX WebX ORA with ORACLE WebX pSQL with PostgreSQL WebX mySQL with MySQL First View So every page files you places into the WebX RootDirectory for your server you can execute via standard cgi bin URL adding your page name cgi bin WebX pagename or cgi bin WebX X_PAGE pagename where X_PAGE is reserved variable for pagename settings From shell you can start it as WebX pagename Your page will be interpreted by WebX and the output will be placed to your browser or to your screen if you are in shell mode Any additional parameters can be passed using standard GET or POST method HTTP server or as command line parameters in shell mode For example HTTP GET http yourhost cgi bin WebX pagename name1 value 1 HTTP GET http youthost cgi bin WebX pagename name1 value amp name2 value2 oo First View WebX Guide Shell WebX pageame namel value name2 value2 Within your page you can access to your variables directly or via multiple functions for example just put name1 to show in this place the current value of the namel You can use also name name2 name1 name In case of name1 will be printed value of the variable which name is a value of namel Standard WebX commands Each line from your page which starts with SPACES or TABS follows with lt WebX will try t
14. from the begin of 1995 and continues its life For the moment I ve ported it on INFORMIX ORACLE MySQL and PostgreSQL of course it turns on any UNIX no comments for NT Installation If you ve downloaded the full binary pre installed version you have just to follow the included installation notes install the product and skip this section In other way if you want to personalize your installation or modify it don t skip So before to do anything you have to be sure what do you want e if you want to use WebX on your Web server you need first to have HTTP server already installed if you want to have an access to the database via WebX you need to have already installed Server or Client software for this RDBMS e you have nothing to do if you want to use WebX as a shell tool why not Now you can install WebX e First you need to create WebX directory mkdir WebX N Installation WebX Guide cd WebX e Second you have to create your environment file named x env and which contains all environment values you wish to be useful to set during WebX execution The format of this file is very sample each line represent a value setting follows syntax NAME VALUE For example cat x env PATH usr bin sbin informix bin oracle bin TMP_DIR tmp INFORMIXDIR informix INFORMIXSERVER ol_goldgate ORACLE_HOME oracle ORACLE_SID dim MYSQL_HOST goldgate A Note the TMP_DIR is the reserved name and it
15. lt end gt lt ul gt lt end gt lt h1 gt The Catalogue Tree lt h1 gt lt hr gt lt call gt PrintTree 0 lt hr gt INSERT lt sqlexec gt insert into book author title year values Author Title Year INSERT WebX Guide lt sqltrap gt OFF lt sql gt insert into CAT_USERS login passwd values Login crypt passwd passwd User Login successfully inserted to the database lt end gt UPDATE lt sqlexec gt update book set author Author_NEW where author Author_OLD DELETE lt sqlexec gt delete from book where author Author Other features There are some other functions and possibilities in WebX which are not documented and not described like WebX transparently extending by new commands and functions dynamic code executing stored in the database imported to any value etc the file uploading from client to server Netscape cookie management etc I did not describe them here because I don t use them very often Thank you very mach to arrive till the end Other features 19
16. o interpret as a WebX command If your command is too long you can cut it into several slices ended by back slash This chapter will present the standard set of commands which you can use on any page managed by WebX SET Syntax lt set gt Name value lt Name gt value lt Name gt lt Name gt lt Name gt value lt Name gt value lt Name gt value lt Name gt value lt Name gt value Action Set value to variable Name if Name doesn t exist it ll be created Any symbols of set can be used as begin end marker of the value string The extensions etc add the set of sample arithmetic operation under variables Examples lt Year gt 1995 lt Name gt Dimitri lt Name gt Name dim lt Year gt lt title gt WebX Name c Year lt title gt Syntax lt include gt pagename Action Include and interpret by WebX another page You can have till 10 recursive includes Every variables are common for all pages during executing the reserved variable DIR keep always the name of the current directory for the current page Examples lt include gt DIR x include SHELL Syntax DS Standard WebX commands WebX Guide lt shell gt shell command Action execute a shell command via system 2 Examples lt shell gt env sort lt shell gt ls l1 Filename IF Syntax lt if gt condition
17. s used to specify the WebX temporary directory The default value is tmp The last you need to create your WebX config file named x config Each line in this file represents the WebX instance configuration for one HTTP server The line format is follow ServerName Port RootDirectory DefaultDataBaseName hold e ServerName and Port your HTTP server name and its port number For using WebX in shell mode you have to put here shell 00 RootDirectory the name of the root directory for WebX script files so only files from this directory and its subdirectories can be executed for the current server configuration As WebX is a kind of page interpreter this restriction protect your site against hacking interpretations of any other files from your hard disk like etc passwd for example e DefaultDataBaseName the default database name uses for any database connection can be replaced by from environment variable like ORACLE_SID e hold is optional value that protect the database name changement for the current server configuration won if the database name is taken For example cat x config goldgate 80 WebX goldgate goldgate 81 WebX admin db_admin hold shell 00 WebX shell Note you can change the default WebX directory by setting the X_HOME value in your environment for personal use and development Now you can copy WebX executable files to your server cgi bin directory or in usr bin for using
18. t lt select name City size 10 multiple gt lt option gt Paris lt option gt Kiev lt option gt St Petersburg lt option gt Moscow lt select gt lt input type hidden name X_PAGE value result_page gt lt input type submit name GO value Start Search gt lt form gt result_page lt query gt select from Country lt Where gt lt OR gt lt h3 gt Search for City s lt h3 gt lt hr gt lt while gt values City City lt br gt lt Where gt Where OR City City lt OR gt or lt end gt lt hr gt lt if gt filled Where lt query gt select from Country where Where Result if it was selected Kiev and Paris you ll have in query select from Country where City Kiev or City Paris WebX Guide WHILE Words lt Count gt 1 2 3 4 5 10 12 56 100 mn lt while gt words Count Count 2 expr Count Count lt br gt lt end gt lt if gt filled SearchWords lt query gt select from hotels where keyword in lt comma gt lt while gt words SearchWords lt query gt query comma SearchWords un lt comma gt lt end gt lt query gt query lt end gt UNLINK Syntax lt unlink gt Filename Action delete the file Examples lt unlink gt tmp myfile FILE Syntax lt file gt Filename lt end gt Action add all We
19. t for example use second kind of SQL call The body between lt sql gt lt end gt will be executed if the SQL query is finished correctly For the SELECT query the body will be executed for every successful FETCH Values fetched from the database become the normal WebX variables with the same names as the column names in SELECT The reserved variable X_sqlnames keeps a name list of all selected columns names are separated by You can switch the lower default to upper case for the column names using lt sqlnames gt uppercase lowercase WebX can keep till 10 default value active SQL queries on the same time so no problem for the recursive selects By default if it takes place some errors during query execution WebX will finish with SQL Error Message If you prefer to personalize the reaction of your application on errors you can force WebX to ignore any SQL errors via lt sqltrap gt call and manage them yourself The reserved variable X_SQLCODE keeps the state after last SQL execution 0 OK lt sqltrap gt ON OFF Also if time to time you change the database mode to support or unsupport transactions you can force WebX to ignore any SQL errors during BEGIN COMMIT ROLLBACK execution lt sqltrap gt OFF_TRANSACTIONS ON_TRANSACTIONS If you execute INSERT statements using autoincrement serial fields the reserverd variable X_INSERT_ID will keep the last inserted value of course if this kind of feature enabled in the
Download Pdf Manuals
Related Search
Related Contents
SNBS Fiches-criteres Habitation Manual - Coverwatches Home Decorators Collection 14702 Instructions / Assembly Cables Direct 3m HDMI m/m CHIRALPAK AS-3 カラム取扱説明書 Pentax R-315EX(NX) User's Manual User`s Manual in English Sony SLV-D930 User's Manual ダウンロード(PDF 0.85MB) Xerox Phaser 6600 User's Manual Copyright © All rights reserved.