easybashweb functions

Only these...

web_message & web_[ok|alert|preformatted|final]_message

web_question

web_text

web_input

web_menu & web_list

web_fselect

web_wait_for

web_adjust

web_tables & web_itable

( MySQL wrappers:

read_mysql_table & [read|insert|update|delete]_mysql_row )

( Note: since version 3.0.0, this library is HTML 5 compliant!!! )

Want know more on easybashweb functions ?

(O) = "web_final_message" differs from other "web_message" types about temp files cleaning and redirection to other URL: you have to put it always in your script (unless you use "clean_temp()" somewhere) -moreover beware web_final_message() "closes" the user session- otherwise temp files will stay in your server for ever... ;

(1) = after "web_question" use, you have to check value in "source easybashweb" command's exit status (or, alternately, in "exit_code" global variable ); values can be: "0" that is "YES", "1" that is "NOT" ;

(2) = "web_input" needs "type" argument before "labels" and "inits" (remember to set it ! ),"type" argument can have only two values: "text" or "password" ;

(3) = "web_menu" function allows only one item selected; on the contrary "web_list" allows multiple choices and with "+" or "-" you can tell it to display them already selected or not ;

(4) = "web_fselect" function uploads user selected file in "${dir_tmp}" directory with same name, and function's output is simply the selected file name -NOTE: uploaded file will not be removed by "web_final_message()" or "clean_temp()" !!! - ;

(5) = "web_wait_for" function basically is simple "web_message" page with a moving bar ( for EasyBashGUI users: this is reason why there is no need of "terminate_wait_for" like in EasyBashGUI, because current page is changed by http server just when it finishes processing) ;

(6) = "web_itable" ( = "web interactive table" ) creates a single interactive table ( = "itable" ) depending on arguments: the only mandatory argument is "-N" that is 'how many columns' are in the itable, optional arguments are "-C" (table colors), "-T" (table title), "-l"

(list mode); itable structure is different depending on "-l" argument is present or not: without "-l" arg, itable is a menu (single choice) and its output can be "NoAction", "Insert", "Modify_[row number]", "Remove_[row number]" , with "-l" arg set, itable is a list (multiple choice menu) and its output can be "NoAction", "Insert", "Modify", "Remove", "Row_[row number]" (e.g.: "Modify Row_3 Row_7 Row_9" );

(7) = "web_tables" ( = "web multiple tables" ) creates one or more tables (not interactive) with no output; it needs "-N" option not only to know tables column numbers, but actually to understand how many tables do you want draw on page ( -N 3,6,8,1 means: => 4 tables, -N 7,1 means: => 2 tables ) -obviously you can set a single table also ( e.g.: web_tables -N 4 "OS" "Creator" "Mascotte" "Family" "Linux" "Torvalds" "Tux" "UNIX" "Windows" "Gates" "a window" "DOS/NT" "FreeBSD" "Berkeley University" "Beastie" "UNIX" -NOTE that, with only one table, table name argument "-T" becomes optional- ) -;

(8) = INPORTANT NOTE: "web_tables" ( = "web multiple tables" ) arguments must include table names before table items ( e.g.: web_tables -T "table A,table B,table C" -N 3,2,4 "table A" "io" "NULL" "noi" "NULL" "lui" "lei" "table B" "IO" "TE" "NOI" "VOI" "LUI" "table C" aaa bbb ccc ddd eee fff ggg hhh iii lll mmm NULL ) ;

(9) = "next_step" sets "$step" variable, that is used to understand at wich point logical flow will be at "next interation" (see examples);

(10) = "set_constant" sets its argument -that is "[variable name]"- as a constant available at all "steps" (that is: "everywhere" in the script): you do need that function if you want a variable from beginning to end, because variables in CGI script simply disappear from a "step" to an other... ;

Example 1:

#!/bin/bash

#

PATH="${PATH}:/usr/local/bin"

HOME="/var/www"

#

source easybashweb

#

if [ "${step}" = "0" ]

then

next_step 1

web_message "START !"

fi

if [ "${step}" = "1" ]

then

next_step 2

web_menu "ONE" "TWO" "THREE"

fi

if [ "${step}" = "2" ]

then

choice="$(cat "${dir_tmp}/${file_tmp}" )"

#

next_step 3

web_message "You selected: \n ${choice}"

fi

if [ "${step}" = "3" ]

then

next_step 4

web_input 3 "text" "ciao" "ciao" "text" "ri-ciao" "NULL" "password" "ri-ri-ciao" "bua"

fi

if [ "${step}" = "4" ]

then

choices="$(cat "${dir_tmp}/${file_tmp}" )"

#

next_step 5

web_message "You selected: \n ${choices}"

fi

if [ "${step}" = "5" ]

then

next_step 6

web_itable -c "red,white" -C "black,yellow" -N 3 "io" "te" "noi" "voi" "lui" "lei"

fi

if [ "${step}" = "6" ]

then

next_step 7

web_itable -c "red,white" -C "black,yellow" -T "My test table..." -N 3 "io" "te" "noi" "voi" "lui" "lei"

fi

if [ "${step}" = "7" ]

then

choices="$(cat "${dir_tmp}/${file_tmp}" )"

#

next_step 8

web_message "You selected: \n ${choices}"

fi

if [ "${step}" = "8" ]

then

next_step 9

web_tables \

-c "red,white" \

-C "black,yellow" \

-T "test table 1,test table 2,test table 3" \

-N 3,2,4 \

"test table 1" "io" "NULL" "noi" "NULL" "lui" "lei" "test table 2" "IO" "TE" "NOI" "VOI" "LUI" "test table 3" aaa bbb ccc ddd eee fff ggg hhh iii lll mmm NULL

fi

if [ "${step}" = "9" ]

then

next_step 10

web_tables \

-c "red,white" \

-C "black,yellow" \

-N 3,2,4 \

"test table 1" "io" "NULL" "noi" "NULL" "lui" "lei" "test table 2" "IO" "TE" "NOI" "VOI" "LUI" "test table 3" aaa bbb ccc ddd eee fff ggg hhh iii lll mmm NULL

fi

if [ "${step}" = "10" ]

then

next_step 11

web_tables \

-c "red,white" \

-C "black,yellow" \

-N 2 \

"test table 1" "io" "NULL" "noi" "NULL" "lui" "lei" "test table 2" "IO" "TE" "NOI" "VOI" "LUI" "test table 3" aaa bbb ccc ddd eee fff ggg hhh iii lll mmm NULL

fi

if [ "${step}" = "11" ]

then

next_step END

web_final_message "https://10.25.178.132/mail/src/login.php" "BYE !!!"

fi

Example 2 :

#!/bin/bash

#

PATH="${PATH}:/usr/local/bin"

HOME="/var/www"

#

source easybashweb

#

if [ "${step}" = "0" ]

then

next_step 1

web_question "Do you like this question?"

fi

if [ "${step}" = "1" ]

then

answer="${exit_code}"

if [ ${answer} -eq 0 ]

then

choice="Ok"

elif [ ${answer} -eq 1 ]

then

choice="Cancel"

fi

#

next_step 2

web_message "You selected: \n ${choice}"

fi

if [ "${step}" = "2" ]

then

next_step 3

web_input 3 text "first value" 0 text "init value" 100 text "end value" 200

fi

if [ "${step}" = "3" ]

then

array_choices=( $(cat "${dir_tmp}/${file_tmp}" ) )

choice_1="${array_choices[0]}"

choice_2="${array_choices[1]}"

choice_3="${array_choices[2]}"

#

next_step 4

web_adjust "Please adjust proper value..." ${choice_1} ${choice_2} ${choice_3}

fi

if [ "${step}" = "4" ]

then

choice="$(cat "${dir_tmp}/${file_tmp}" )"

#

next_step 5

web_message "You selected: \n ${choice}"

fi

if [ "${step}" = "5" ]

then

next_step END

web_final_message "https://10.25.178.132/mail/src/login.php" "BYE !!!"

fi