home *** CD-ROM | disk | FTP | other *** search
- <includeonce
- // Filename: dba.hei version 1.2
- // Release date: March 3rd, 1997
- //
- // (C) 1996-97 H.E.I. GmbH and suppliers all rights reseved
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions
- // are met:
- // 1. Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- // 2. Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the distribution.
- // 3. Neither the name of H.E.I. GmbH nor the names of its contributors
- // may be used to endorse or promote products derived from this software
- // without specific prior written permission.
- // 4. The complete licensing conditions of heitml apply also to this file,
- // be sure to have read and accepted these conditions before using this
- // file. This file may be used and modified freely in conjunction with
- // a valid heitml license.
- //
- // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- // IN NO EVENT SHALL THE H.E.I. OR CONTRIBUTORS BE LIABLE FOR ANY
- // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- if false; def sessionUrl; /def; def sessionHidden; /def; /if;
-
- // Embedded customizable database application
- // (c) H.E.I. may be used freely in combination with heitml
- // You can easily build an application processing one relation
- // in the database. You can insert a form in your page to display,
- // modify or delete records in the database.
- // For complete documentation and examples see www.h-e-i.de
-
-
- // How to use it:
- // First use <dbapp app, rel, maint=false> to define an application.
- // rel gives the name of the database relation
- // app gives a name to the application,
- // maint sets maintenance mode, be sure to switch it off in real operation
-
- // Then you can insert several checking and control statements:
- // dbappcreate is an environment and can contain create table
- // statements. The are performed with action=create
- // and maint=true
-
-
- // Insert the main dbapp form
- def dbapp *app, rel, src=SrvLocalUrl, maint=false;
- app=emptytuple;
- app.rel = rel;
- app.maint = maint;
- app.keyfi = emptytuple; /* fields names of key */
- app.fitype = emptytuple; /* types of special fields */
- app.src = src; /* page to call application */
- /def;
-
- defenv dbacreate app;
- ff.action = default(ff.action);
- // > DBACREATE <? ff.action> <
- if app.maint;
- if (ff.action=="drop" || ff.action=="drcreate");
- dbupdate > drop table <? app.rel> </dbupdate;
- /if;
- if (ff.action=="create" || ff.action=="drcreate");
- defbody
- > Tables Created. <
- /if
- /if
- /defenv
-
- def dbakeyfield app fn order="asc";
- app.keyfi[fn]=order;
- /def;
-
- def dbafitype app fn ty;
- app.fitype[fn]=ty;
- /def;
-
- def dbaTinteger app fn;
- app.fitype[fn]="int";
- /def;
-
- def dbaTreal app fn;
- app.fitype[fn]="real";
- /def;
-
-
- def dbaTtext app fn;
- app.fitype[fn]="hstv";
- /def;
-
-
- def dbaFixKey app k;
- i=0;
- if k != null;
- while (i<len(app.keyfi));
- n = fname(app.keyfi[i]);
- t = app.fitype[n];
- if (t=="int"); k[n]=integer(k[n]); /if;
- if (t=="real"); k[n]=real(k[n]); /if;
- i=i+1;
- /while;
- /if
- /def;
-
- defenv dbaKeyComputed app;
- app.keycomputed = "t";
- if isdecl(ff.r);
- if isempty(ff.k) && !isempty(ff.submit);
- i=0;
- while (i<len(app.keyfi));
- n = fname(app.keyfi[i]);
- if !isempty(ff.r[n]); break; /if;
- i=i+1;
- /while;
- if (len(app.keyfi)<=i);
- defbody;
- /if;
- /if;
- /if;
- /defenv;
-
- // do not perform an action, but do a redisplay an error
- def dbaredisplay; ff.redisplay=true; /def;
-
- defenv dbaerrmsg headmsg="No Update Performed">
- <hr><h2><font color="Red"><h2><? headmsg html></h2><br>
- <defbody></font></h2><hr><dbaredisplay;ff.dbalasterrmsg=headmsg;
- /defenv
-
-
- defenv fehler;
- dbaerrmsg "Änderung noch nicht durchgeführt.";defbody;/dbaerrmsg;
- /defenv;
-
- // *********** Subroutines *************
-
- def dbaKeyQueryCmp key keyfi rel;
- if isNull(key); return ""; /if;
- assign kq;
- if 1<len(key) >(< /if;
- j=0;
- while j<len(key);
- if (0<j)> OR < /if;
- if 1<len(key) >(< /if;
- i=0;
- while i<j;
- if (0<i)> AND </if;
- ? key[i]"Qn";
- i=i+1;
- /while
- if (0<i)> AND </if;
-
- rel1 = rel;
- if keyfi[j]=="desc";
- if rel1==">"; rel1="<"; else rel1=">"; /if;
- /if;
- if (j==len(key)-1); rel1=rel1+"="; /if
- ?fname(key[j]); ? rel1; ? key[j] "Q";
- j=j+1;
- if 1<len(key) >)< /if;
- /while
- if 1<len(key) >)</if;
- /assign;
- return kq;
- /def;
-
- def dbaFieldOrder app desc=false;
- i=0;
- assign s;
- while (i<len(app.keyfi));
- if (0<i) >, </if;
- ? fname(app.keyfi[i]);
- if (app.keyfi[i]=="desc" && !desc) || (app.keyfi[i]!="desc" && desc);
- > DESC <
- /if;
- i=i+1;
- /while;
- /assign;
- return s;
- /def;
-
-
-
- // execute a SQL update statement, update
- // process all form fields r. and h.
- def dbaperfupdate app key rec;
- dbupdate
- > update <?app.rel> set <
- let i=0;
- while i<len(rec);
- if i!=0 >, </if;
- ty = app.fitype[fname(rec[i])];
- if ((Contains(SrvDbSys,"YARD") || Contains(SrvDbSys,"ODBC") ||
- Contains(SrvDbSys,"ADABAS")) && ty=="hstv");
- ? fname(rec[i]) >=< ? rec[i] hstv;
- else if (ty=="int");
- ? rec[i] "AnNV">=<? integer(rec[i])"ANN";
- else if (ty=="real");
- ? rec[i] "AnNV">=<? real(rec[i])"ANN";
- else
- ? rec[i]"Qn";
- /if; /if; /if;
- i=i+1;
- /while;
- > where <? key" AND %Qn">
- </dbupdate;
- /def;
-
- // execute a SQL insert statement
- // process all form fields r. and h.
- def dbaperfinsert app key rec;
- i=0; upd=""; insfn= ""; ihstv=0;
-
- dbupdate
- > insert into <?app.rel> ( <? rec"QnNV"> )
- values (
- <
- while i<len(rec);
- if i!=0 >, </if;
- ty = app.fitype[fname(rec[i])];
- if ((Contains(SrvDbSys,"YARD") || Contains(SrvDbSys,"ODBC") || Contains(SrvDbSys,"ADABAS")) && ty=="hstv");
- ? rec[i] hstv;
- else if (ty=="int");
- ? integer(rec[i]) "ANN";
- else if (ty=="real");
- ? real(rec[i])"ANN";
- else
- ? rec[i]"Q";
- /if; /if; /if;
- i=i+1;
- /while;
- >)<
- /dbupdate;
- /def;
-
- // execute a delete
- def dbaperfdelete app key;
- dbupdate>
- delete from <? app.rel> where <? key" AND %Qn">
- </dbupdate
- /def;
-
-
- def dbaupdateaction app;
- if (!isnull(ff.submit)); return "submit"; /if;
- if (!isnull(ff.delete)); return "delete"; /if;
- return null;
- /def;
-
-
- // read the record determined by key into r
- // if not found r is null afterwards
- defenv dbaReadRecord app *r key=ff.k;
- r = null; dbaFixKey app key;
- dbquery q>
- select * from <? app.rel> where <? key" AND %Qn">
- <dbrow;
- app.q=q; r=q; defbody;
- /db;
- /defenv;
-
-
- def dbasetaction a;
- // if !isnull(a);
- ff[a]="t";
- // /if;
- /def;
-
- def dbaCheckKey app rec;
- i=0;
- while (i<len(app.keyfi));
- if (isempty(rec[fname(app.keyfi[i])]));
- dbaerrmsg > The field <? fname(app.keyfi[i])> must be given
- </dbaerrmsg;
- /if;
- i=i+1;
- /while;
- /def;
-
- // perform database update or insert or delete,
- // depending on the action
- // the record is read beforehand and the body is executed
- // if the record is found
- defenv dbaupdate app *r *o action=dbaupdateaction(app) key=default(ff.k)
- rec=default(ff.r) submitaction=null ;
- r=rec; o=null;
- if action=="submit";
- dbaFixKey app key;
- if !isnull(key) && !isempty(default(key,rec)[0]); // an update
- dbareadrecord app o key=key;
- app.q=o;
- defbody;
- if isnull(ff.redisplay);
- dbaperfupdate app key=key rec=rec;
- dbasetaction submitaction;
- /if;
- /dbareadrecord;
- if o==null; dbaerrmsg> Record has been deleted meanwhile </dbaerrmsg;
- /if;
- app.afterupdate = "t";
- else
- key = copy(app.keyfi); TuProject (key,rec);
- dbareadrecord app o key=key;
- dbaerrmsg > Record already stored in database </dbaerrmsg;
- /dbareadrecord;
- defbody;
- dbaCheckKey app rec;
- if isnull(ff.redisplay);
- dbaperfinsert app key=key rec=rec;
- dbasetaction submitaction;
- ff.k=key;
- /if;
- app.afterinsert = "t";
- /if;
- /if;
- /defenv
-
- defenv dbaAfterInsert app *r *o action=dbaupdateaction(app) key=default(ff.k)
- rec=default(ff.r) submitaction=null ;
- r=rec; o=null;
- if action=="submit" && default(app.afterinsert,"") == "t";
- defbody;
- /if;
- /defenv
-
- defenv dbaAfterUpdate app *r *o action=dbaupdateaction(app) key=default(ff.k)
- rec=default(ff.r) submitaction=null ;
- r=rec; o=null;
- if action=="submit" && default(app.afterupdate,"") == "t";
- defbody;
- /if;
- /defenv
-
- defenv dbaDelete app *r action=dbaupdateaction(app) key=default(ff.k)
- deleteaction="first";
- if action=="delete";
- dbaFixKey app key;
- if isempty(key);
- dbasetaction deleteaction;
- else
- dbquery q>
- select * from <? app.rel> where <? key" AND %Qn">
- <dbrow;
- app.q = q; r=q;
- defbody;
- /db;
- if isnull(ff.redisplay);
- dbaperfdelete app key=key;
- dbasetaction deleteaction;
- else
- ff.redisplay=null;
- ff.show=true;
- /if;
- /if
- /if;
- r=null; app.afterdelete="t";
- /defenv;
-
- defenv dbaAfterDelete app *r *o action=dbaupdateaction(app) key=default(ff.k)
- rec=default(ff.r) submitaction=null ;
- r=rec; o=null;
- if action=="delete" && default(app.afterdelete,"") == "t";
- defbody;
- /if;
- /defenv
-
-
- def dbaKeyUpdate;
- if isdecl(ff.k) && isdecl(ff.r) && !isdecl(ff.redisplay);
- TuProject (ff.k ff.r);
- /if
- /def;
-
-
- // show field content given by val
- def dbafi app fn size=10 maxsize=size def=null;
- if !isnull(app.keyfi[fn]);
- if app.keywri && default(app.keycomputed,"") == "">
- <input name="<
- if app.keyrec; >r.< else >k.< /if
- ><?fn>" size=<?size> maxlength=<?maxsize> value=<? default(app.q[fn]) quoted>>
- <else
- if isempty(app.q[fn]); ? def html; else ? app.q[fn]; /if;
- /if;
- else
- if app.writeable >
- <input name="r.<?fn>" size=<?size> maxlength=<?maxsize> value=<? default(app.q[fn]) quoted>>
- <else
- if isempty(app.q[fn]); ? def html; else ? app.q[fn]; /if;
- /if;
- /if;
- /def;
-
- def dbamailto app fn size=30 maxsize=size def=null;
- if app.writeable;
- dbafi app fn size maxsize;
- else
- if !isempty (app.q[fn]);
- > <a href=mailto:<? app.q[fn]>><? app.q[fn]></a> <
- else
- ? def html;
- /if;
- /if;
- /def
-
- def dbalink app fn size=30 maxsize=size def=null;
- // app.q[fn]=default(app.q[fn],"http://");
- if app.writeable;
- dbafi app fn size maxsize;
- else
- if !isempty (app.q[fn]);
- > <a href="<
- if !contains(app.q[fn],"://") >http://< /if;
- ><? app.q[fn]>"><? app.q[fn]></a> <
- else
- ? def html;
- /if;
- /if;
- /def
-
-
- def dbaTextArea app fn rows=10 cols=60 wrap="physical" disp="normal";
- if app.writeable >
- <textarea name="r.<?fn>" cols=<? cols> rows=<? rows> wrap=<? wrap quoted>><?default(app.q[fn])></textarea>
- <else
- if disp=="pre">
- <pre>
- <? default(app.q[fn])>
- </pre>
- < else
- if disp=="html">
- <? default(app.q[fn]) html>
- < else
- if disp=="heitml">
- <? default(app.q[fn]) heitml>
- < else>
- <? default(app.q[fn])>
- < /if;
- /if;
- /if;
- /if;
- /def;
-
-
- defenv dbacheckbox app fn trueval="T" falseval="";
- if app.writeable;
- defbody;
- > <input name="r.<?fn>" type="hidden" value=<?falseval quoted>>
- <input name="r.<?fn>" type="checkbox" value=<?trueval quoted> <
- if app.q[fn]==trueval> checked </if
- > > <
- else
- if app.q[fn]==trueval;
- defbody;
- /if;
- /if;
- /defenv
-
- defenv dbaRadio app fn val;
- if app.writeable;
- > <input name="r.<?fn>" type="radio" value=<?val quoted> <
- if app.q[fn]==val> checked </if
- > > <
- defbody;
- else
- if app.q[fn]==val;
- defbody;
- /if;
- /if;
- /defenv
-
- defenv dbaSelect app fn;
- app.selectvalue = trim(default (app.q[fn]," "));
- if app.writeable;
- > <select name="r.<?fn>">
- <defbody>
- </select>
- <
- else
- defbody;
- /if;
- /defenv;
-
- def dbaOptionV app value;
- if app.writeable;
- > <option value=<? value quoted> <
- if (app.selectvalue==value) > selected < /if;
- > > <? value;
- else
- if (app.selectvalue==value); ? value; /if;
- /if
- /def;
-
- defenv dbaOption app value;
- if app.writeable;
- > <option value=<? value quoted> <
- if (app.selectvalue==value) > selected < /if;
- > > <defbody;
- else
- if (app.selectvalue==value); defbody; /if;
- /if
- /defenv;
-
-
- def dbatfi app fn size maxsize=size def=null>
- <tr> <td> <b> <?fn> </b> </td> <td> <dbafi app fn size maxsize def=def> </td> </tr>
- </def;
-
- def dbatab app fn size maxsize=size>
- <td> <dbafi app fn size maxsize> </td>
- </def;
-
- def dbashowaction app;
- if (!isnull(ff.redisplay)); return "redisplay"; /if;
- if (!isnull(ff.empty)); return "empty"; /if;
- if (!isnull(ff.showemp)); return "showemp"; /if;
- if (!isnull(ff.show)); return "show"; /if;
- if (!isnull(ff.display)); return "display"; /if;
- if (!isnull(ff.submit)); return "no"; /if;
- if (!isnull(ff.delete)); return "no"; /if;
- return "no";
- /def;
-
- defenv dbaform app *r action=dbashowaction(app)
- key=default(ff.k) rec=default(ff.r)
- keyact="no";
- // action what to do
- // empty show an empty form
- // showemp show the record designated by the key, if not found show empty form
- // show just show record, if not found show nothing r==null
- // display display not writeable
- // redisplay show just entered record
- // keyact
- // no key fields are not writeable
- // upd key fields may be updated
- // cpy key fields can be changed and cause copying
- // del key fields are shown writeable and empty
- // --------------------------------------------------------
- // internal options of show
- // app.writeable show fields writeable
- // app.keywri show key fields writeable
- // app.keyrec key fields get r prefix
- // --------------------------------------------------------
- // ? "Action = "; ? action;
- r=null; app.key=key;
- if action=="empty";
- r=default(rec,emptytuple); app.q=r; app.writeable=true; app.keywri=true; app.keyrec=true;
- >
- <form action="<? app.src>" method="post">
- <sessionHidden>
- // Here we could insert duplication functionality
- <defbody>
- </form>
- <
- /if
- if action=="redisplay";
- dbaFixKey app key;
- r=copy(rec); app.q=r; app.writeable=true; app.keywri=false; app.keyrec=false;
- if keyact!="no"; app.keywri=true; /if;
- >
- <form action="<? app.src>" method="post">
- <sessionHidden>
- <if keyact=="no" || keyact=="upd";
- if !isnull(key);
- k=key; ? k "Fht";
- /if;
- app.keyrec=true;
- /if>
- <defbody>
- </form>
- <
- /if;
- if action=="show"||action=="showemp"||action=="display">
- <dbaFixKey app key>
- <dbquery q >select * from <? app.rel> where <? key" AND %Qn"><
- dbrow
- r=q; app.q=q; app.writeable=true; app.keywri=false; app.keyrec=false;
- if keyact!="no"; app.keywri=true; /if;
- if action=="display"; app.keywri=false; app.writeable=false; /if;
- >
- <form action="<? app.src>" method="post">
- <sessionHidden>
- <if keyact=="no" || keyact=="upd"; k=key; ? k "Fht"; app.keyrec=true;/if>
- <defbody>
- </form>
- <
- dbempty
- gl.found=false;
- r=key; app.q=r;
- if action=="showemp";
- app.writeable=true; app.keywri=false; app.keyrec=true;
- >
- <form action="<? app.src>" method="post">
- <sessionHidden>
- <if keyact=="no"; k=key; ? k "Fht"; else app.keywri=true;/if>
- <defbody>
- </form>
- <
- /if
- /dbquery
- /if
- /defenv;
-
-
-
- defenv dbaAshow app k=default(app.key) addurl="";
- if !isnull(k) ><a href=<?app.src>?show=t&<? k"Unt"><? addurl>&<sessionUrl>> <defbody></a> </if
- /defenv;
-
- defenv dbaAdisplay app k=default(app.key) addurl="";
- if !isnull(k) ><a href=<?app.src>?display=t&<? k "Unt"><? addurl>&<sessionUrl>> <defbody></a> </if
- /defenv;
-
- defenv dbaAshowemp app k=default(app.key) addurl="";
- if !isnull(k) ><a href=<?app.src>?showemp=t&<? k "Unt"><? addurl>&<sessionUrl>><defbody></a></if
- /defenv;
-
- defenv dbaAdelete app key=default(app.key) addurl="";
- if !isnull(k) ><a href=<?app.src>?delete=t&<? k "Unt"><? addurl>&<sessionUrl>> <defbody></a></if
- /defenv;
-
- defenv dbaAPdelete app key=default(app.key);
- if app.writeable;
- > <input type="submit" name="delete" value="<defbody>"> <
- /if;
- /defenv;
-
- defenv dbaPDeleteForm app k=default(app.key);
- if !isnull(k);
- app.writeable=true;
-
- > <form action="<? app.src>" method="post">
- <sessionHidden>
- <? k "Fht"; defbody>
- </form> <
- /if;
- /defenv;
-
- defenv dbaAsubmit app;
- if app.writeable> <input type="submit" name="submit" value="<defbody>"></if
- /defenv;
-
- defenv dbaAreset app;
- if app.writeable> <input type="reset" name="reset" value="<defbody>"></if
- /defenv;
-
- defenv dbaAnext app k=default(app.key) addurl="";
- if !isnull(k)> <a href=<?app.src>?next=t&<? k "Unt">&ofs=<?
- app.cnt-app.i+1><? addurl>&<sessionUrl>><defbody></a></if
- /defenv;
-
- defenv dbaAprev app k=default(app.startkey) addurl="";
- // > app.cnt = <?app.cnt> app.i= <?app.i> <
- if !isnull(k)> <a href=<?app.src>?prev=t&<? k "Unt">&ofs=<?
- 1><? addurl>&<sessionUrl>><defbody></a></if
- /defenv;
-
- defenv dbaAfirst app addurl="">
- <a href=<?app.src>?first=t<? addurl>&<sessionUrl>><defbody></a>
- </defenv;
-
- defenv dbaAlast app addurl="">
- <a href=<?app.src>?last=t<? addurl>&<sessionUrl>><defbody></a>
- </defenv;
-
- defenv dbaAempty app addurl="">
- <a href=<?app.src>?empty=t<?addurl>&<sessionUrl>><defbody></a>
- </defenv;
-
-
- def dbalistaction app;
- if (!isnull(ff.first)); return "first"; /if;
- if (!isnull(ff.last)); return "last"; /if;
- if (!isnull(ff.next)); return "next"; /if;
- if (!isnull(ff.prev)); return "prev"; /if;
- return "no";
- /def;
-
- // return the key of the cnt-next record, starting with key
- def dbaScrollDown app key cnt;
- i=0;
-
- // > Scroll Down <assign x><? key "Q"></assign><?x> <br> <
- dbquery q> select <? app.keyfi"QNVn">
- from <? app.rel>
- where <? dbaKeyQueryCmp(key,app.keyfi, ">")> <? app.cond>
- ORDER BY <?dbafieldorder (app)>
- <
- dbrow
- if i==cnt; return q; /if;
- i=i+1;
- /db;
- return null;
- /def;
-
- // return the key of the cnt-prev record, starting with key
- def dbaScrollUp app key cnt;
- i=0;
- qu = dbaKeyQueryCmp(key,app.keyfi,"<");
- // ? isempty(qu); ? isempty(app.cond);
- if (isempty(qu) && isempty(app.cond));
- qu = "";
- else
- if (isempty(qu)); qu = " where "+ substring (app.cond,4,len(app.cond));
- else qu= "where " + qu + app.cond; /if;
- /if;
- // > Scroll Up <showtuple key> <
- dbquery q> select <? app.keyfi"QNVn"> from <? app.rel>
- <? qu>
- ORDER BY <?dbafieldorder (app,true)>
- <
- dbrow
- // > Read <?i> <?cnt><showtuple q> <
- if i==cnt; return q; /if;
- i=i+1;
- /db;
- return null;
- /def;
-
- def dbaScroll app key cnt;
- // > Scroll cnt = <? cnt> <
- if 0<=cnt; return dbaScrollDown(app, key, cnt);
- else return dbaScrollUp (app, key, -cnt); /if;
- /def
-
-
- defenv dbaTable app action=dbalistaction(app) key=default(ff.k) cnt=10
- ofs=integer(default(ff.ofs,0)) cond="";
- app.keywri=false; app.writeable=false; app.i=0; r=null; app.cnt=cnt;
-
-
-
- // > Here we are <? ofs> <?cnt> <
-
- if action=="no"; return; /if;
- dbaFixKey app key;
- app.cond="";
- if !isempty(cond); app.cond=" AND "+cond; /if;
- if action=="first"; key = default(app.firstkey); /if;
- if action=="next"; key = dbaScroll (app, key, ofs);
- // if already at end of file, just do a last
- if isnull(key); key = dbaScroll (app, null, -cnt+2); /if;
- /if;
- if action=="prev"; key = dbaScroll (app, key, ofs-cnt-1); /if;
- if action=="last"; key = dbaScroll (app, null, -cnt+2); /if;
- app.key = key;
- defbody;
- /defenv;
-
-
- defenv dbaTableEntry app *r;
- r=null;
- qu = dbaKeyQueryCmp(app.key,app.keyfi,">");
- if (isempty(qu) && isempty(app.cond));
- qu = "";
- else
- if (isempty(qu)); qu = " where " + substring (app.cond,4,len(app.cond));
- else qu= "where " + qu + app.cond; /if;
- /if;
-
- dbquery q> select *
- from <? app.rel>
- <? qu>
- ORDER BY <? dbafieldorder (app)>
- <
- dbrow r=q; app.q=q; app.key=copy (app.keyfi); TuProject(app.key,r);
- if app.i==0; app.startkey=app.key; /if;
- defbody;
- // > <?app.i> <
- // showtuple q;
- app.i=app.i+1;
- if (app.cnt<=app.i); break; /if;
- /db;
- /defenv;
-
-
- def dbapasswordcheck app master="*";
- if isempty(ff.r.password);
- dbaerrmsg> You MUST specify a password. You can use it to modify or
- delete your database entry </dbaerrmsg;
- else
- ff.r.password=crypt(trim(ff.r.password));
- if !isnull(app.q);
- // > Compare <? app.q.password> and <? ff.r.password> <
- if trim(default(app.q.password,""))!=trim(ff.r.password) &&
- trim(ff.r.password)!=master;
- dbaerrmsg> The password you entered did not match the one in our database. </dbaerrmsg;
- else
- ff.r.password = app.q.password;
- /if;
- /if;
- /if;
- /def;
-
-
- def dbafipassword app fn="Password" size=10 pref="<b> Password: </b>" ;
- if app.writeable;
- > <? pref html>
- <input type="Password" size=<? size> name="r.<? fn>"> <
- /if
- /def;
- >
-