#!/usr/bin/perl # program to compile WOB files. See http://wob.sourceforge.com # Copyright (c) 2000, John Hanna, # This program may be distributed under the terms of this General Public # License. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED # BY APPLICABLE LAW. # http://www.opensource.org/licenses/gpl-license.html # ## set the following to enable these features $CompiledOutput='/usr/users/www/pma/debug'; ## file name for compiled output $sqllog='/usr/users/www/pma/sqllog'; ## file for logging SQL info ## this is the location of the directory to keep session data $_sid_base='/home/groups/wob/sid/'; $_sid_base='/usr/users/www/pma/sid/'; $_SID_TIMEOUT=60*60*2; ## sessions time out after 2 hours without use use DBI; ########################################## ## this part compiles the wob file undef $/; $_=<>; ## read wob file ### looking for # ###name and ##name defs # -> links # $var substitutions -> hash of session # &func calls # `` perl `` blocks # handle buttons # put existing values into form info # #insert filename s/\r//g; ($_head)=split(/

##/i,$_,2); $_="\n".substr($_,length($_head)); $_head=~s/\s*$//; $_head=~s/\r//g; $_head="" unless $_head; #($tail)=/###end\b.*([^\000]*)$/i; #$tail="\n" unless $tail; # do inserts #print join("\n",/([^#])#(insert|include)\s+(\S+)/g),"\n"; while(s/([^#])#(insert|include)\s+([^\s<]+)/$1.&_insert($3)/ge) {} #&wf("/usr/users/www/pma/d3",$_); ($_base)=/###(\w+)/i; ($defaultDB)=/\$(\w+) *= *DBI.*connect/; s/;\]/\002/gi; $sqlcmds='select|create|alter|optimize|check|repair|delete|join|insert|replace|load|update|use|flush|kill|show|explain|describe|lock|set|grant'; s/\[ *(($sqlcmds)\s[^\002]+)\002/"&sql(\$$defaultDB,qq[".&_autoquote($1).";])"/gie; s/\002/;]/g; sub _autoquote { local($_)=@_; s/'\$(\w+)'/\\000\$$1\\000/g; $_; } #while(/``([^\000]*?)``/g) {local($_)=$1; # print STDERR "Runaway `` script includes $1\n" if /[^#](###?\w+)/; #} ## Private s/\bprivate\s+\$(\w+);/$_privates{$1}=''/ge; s/\bprivate\s+\$(\w+)/$_privates{$1}="\$$1"/ge; $_privates=join('|',keys %_privates); ## Var: $SQL s/\$SQL(\w+)/\$SQL{$1}/g; ## Var: session s/\$(?!SQL)([a-zA-Z]\w*)/\$_session{$1}/g; ## code s/([^\000]*?)<\/script>/&_code2/gie; #s/;[<>\r\n \tpbr\/]*\]/\002/gi; s/

``/``/gi; s/``<\/p>/``/gi; s/``/\002/g; s/\002([^\002]*)\002/&_code/ge; ## "function" calls s/([\s>])&(\w+)/$1\002!!$2;\002/g; ##