|
Post by meerkat on Aug 26, 2019 16:54:56 GMT -5
Was trying to convert some PHP code to Liberty Basic and it was taking forever. So decided to write a program to help in the conversion. It worked good enough that I thought others may be interested.
There are some things that there is no conversion. So depending on the PHP program it will convert anywhere from 80% to 95%.
PHP uses underscore in their variables. You have the option to convert it to dot (.) or the next character to caps. So in PHP a variable of $seq_num can be converted to seq.num$ or seqNum$.
' --------------------------------------- ' PHP to LB conversion ' php2lb.bas ' --------------------------------------- cr$ = chr$(13) lf$ = chr$(10) tab$ = chr$(9) crlf$ = cr$;lf$ a$ = "C"
[inLoop] input "Convert (_) to [D]ot or next [C]ap ";cd$ cls cd$ = upper$(cd$) if cd$ = "C" then goto [loadPHP] if cd$ = "D" then goto [loadPHP] print "***ERRIR*** Please enter D=Dot or C=Cap" goto [inLoop]
[loadPHP] filedialog "Find a PHP program File", "*.php", loadPHP$ if loadPHP$ = "" then notice "No file selected.";crlf$;"Thank you and have a great day!" wait end if i = 1 while word$(loadPHP$,i,"\") <> "" ' seperate file name from path a$ = word$(loadPHP$,i,"\") 'print i;" ";a$ i = i + 1 WEND i = i - 1 PHPfile$ = word$(loadPHP$,i,"\") ' the file name loc$ = word$(loadPHP$,1,PHPfile$) ' the file location (path)
a$ = "Loading ";crlf$;"PHP file: ";PHPfile$;cr$;"Location: ";loc$ confirm a$;answer$ if answer$ = "no" then wait
[PHPload1] sqliteconnect #mem, ":memory:" mem$ = "CREATE TABLE php ( seqNum int, code text, cmt int )" #mem execute(mem$) seqNum = 0
'get contents of uploaded file into string variable print "Input PHP file: ";loadPHP$ open loadPHP$ for input as #f a$ = "" while EOF(#f)=0
input #f, a1$
a$ = a$ ;a1$;cr$
wend close #f
ln = len(a$) cr = instr(a$,cr$) lf = instr(a$,lf$)
a$ = strRep$(a$,lf$,cr$) ' lf to cr a$ = strRep$(a$,"'",chr$(34)) ' single to double quote a$ = strRep$(a$,tab$," ") ' tabs to space a$ = strRep$(a$,"==","=") ' == to = a$ = lower$(a$) seqNum = 0 i1 = 1 [loop] i = instr(a$,cr$,i1) if i > 0 then a1$ = " ";strip$(mid$(a$,i1,i - i1));" " a1$ = strRep$(a1$,";","") if INSTR(a1$,tab$) > 0 then a1$ = strRep$(a1$,tab$," ") ' tabs to space if INSTR(a1$," ") > 0 then a1$ = strRep$(a1$," "," ") ' single space if INSTR(a1$,"&&") > 0 then a1$ = strRep$(a1$,"&&","AND") ' && to ANC if INSTR(a1$,"echo") > 0 then a1$ = strRep$(a1$,"echo","PRINT") ' echo to PRINT if INSTR(a1$," . ") > 0 then a1$ = strRep$(a1$," . "," + ") ' dot (.) to plus (+) if INSTR(a1$,"[") > 0 then a1$ = strRep$(a1$,"[","(") ' [ to ( if INSTR(a1$,"]") > 0 then a1$ = strRep$(a1$,"]",")") ' ] to ) if INSTR(a1$,"else") > 0 then ' a1$ = strRep$(a1$,"{","") ' { to blank a1$ = strRep$(a1$,"}","") ' } to blank end if if cd$ <> "C" then ' convert _ to next char to cap a1$ = strRep$(a1$,"_",".") ' or to . else [loop1] j = INSTR(a1$,"_") if j > 0 then a1$ = left$(a1$,j - 1) + upper$(mid$(a1$,j + 1,1)) + mid$(a1$,j + 2) goto [loop1] end if end if ' ------------------------------ ' PHP variables start with $ ' move $ to end of variable ' ------------------------------ j1 = 0 [loop2] j = INSTR(a1$,"$", j1) if j > 0 then j1 = INSTR(a1$," ",j) if j1 = 0 then j1 = len(a1$) j1a = INSTR(a1$,"(",j) if j1a > 0 then j1 = MIN(j1,j1a) j1a = INSTR(a1$,")",j) if j1a > 0 then j1 = MIN(j1,j1a) j1a = INSTR(a1$,",",j) if j1a > 0 then j1 = MIN(j1,j1a) j2 = (j1 - j) - 1 if j > 0 and j1 > 0 and j2 > 0 then a1$ = left$(a1$,j - 1) + mid$(a1$,j+1, j2) + "$" + mid$(a1$,j1) goto [loop2] end if end if
' -------------------------------- ' PHP comments to RB comments ' PHP comments start with /* ' and ebd wutg */ ' -------------------------------- [cmtOn] if cmtOn > 0 then a1$ = "'' " + a1$ if INSTR(a1$,"*/") > 0 then ' check for end of comments cmtOn = 0 'print "============ COMMENT OFF ============" aa1$ = "''" + word$(a1$,1,"*/") seqNum = seqNum + 1 cmt = 1 mem$ = "INSERT INTO php VALUES(";seqNum;",'";aa1$;"',";cmt;")" #mem execute(mem$) 'print mem$ a1$ = word$(a1$,2,"*/") else goto [skipCmt] end if end if cmt = INSTR(a1$,"//") if cmtOn = 0 then cmtOn = INSTR(a1$,"/*") ' Turn comments on if cmtOn > 0 then 'print "============ COMMENT ON =============";a1$ aa1$ = trim$(word$(a1$,1,"/*")) if aa1$ <> "" then seqNum = seqNum + 1 cmt = INSTR(aa1$,"//") mem$ = "INSERT INTO php VALUES(";seqNum;",'";aa1$;"',";cmt;")" #mem execute(mem$) 'print mem$ end if a1$ = word$(a1$,2,"/*") goto [cmtOn] end if [skipCmt] seqNum = seqNum + 1 mem$ = "INSERT INTO php VALUES(";seqNum;",'";a1$;"',";cmt;")" #mem execute(mem$) 'print mem$ [skip] i1 = i + 1 goto [loop] end if
s = 1 [nxtForeach] mem$ = "SELECT * FROM php WHERE code LIKE '% foreach %' AND seqNum >= ";s;" ORDER BY seqNum LIMIT 1" #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() 'print using("########",seqNum);" ";code$ i = INSTR(code$," foreach ") i1 = INSTR(code$,"{",i) if i1 > 0 then code$ = left$(code$,i1 - 1) + mid$(code$,i1 + 1) code$ = strRep$(code$,"foreach","FOR") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum #mem execute(mem$) 'print mem$ else mem$ = "SELECT * FROM php WHERE code LIKE '%{%' AND seqNum > ";seqNum;" ORDER BY seqNum LIMIT 1" #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() code$ = strRep$(code$,"{","") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum #mem execute(mem$) 'print mem$ end if end if mem$ = "SELECT * FROM php WHERE code LIKE '%}%' AND seqNum >= ";seqNum;" ORDER BY seqNum LIMIT 1" #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() code$ = strRep$(code$,"}","NEXT") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum #mem execute(mem$) 'print mem$ end if s = seqNum + 1 goto [nxtForeach] end if
s = 1 [nxtIf] mem$ = "SELECT * FROM php WHERE code LIKE '% if %' AND seqNum >= ";s;" ORDER BY seqNum LIMIT 1"
'print mem$
#mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() 'print using("########",seqNum);" ";code$ 'input x i = INSTR(code$," if ") i1 = INSTR(code$,"{",i) if i1 > 0 then code$ = left$(code$,i1 - 1) + " THEN " + mid$(code$,i1 + 1) mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum 'print mem$ #mem execute(mem$) else mem$ = "SELECT * FROM php WHERE code LIKE '%{%' AND seqNum > ";seqNum;" ORDER BY seqNum LIMIT 1" 'print mem$ #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() code$ = strRep$(code$,"{","THEN") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum 'print mem$ #mem execute(mem$) end if end if mem$ = "SELECT * FROM php WHERE code LIKE '%}%' AND seqNum >= ";seqNum;" ORDER BY seqNum LIMIT 1" 'print mem$ #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() code$ = strRep$(code$,"}","END IF") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum 'print mem$ #mem execute(mem$) end if s = seqNum + 1 goto [nxtIf] end if
s = 1 [nxtWhile] mem$ = "SELECT * FROM php WHERE code LIKE '% while %' AND seqNum >= ";s;" ORDER BY seqNum LIMIT 1"
'print mem$
#mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() 'print using("########",seqNum);" ";code$ i = INSTR(code$," while ") i1 = INSTR(code$,"{",i) if i1 > 0 then code$ = left$(code$,i1 - 1) + mid$(code$,i1 + 1) mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum 'print mem$ #mem execute(mem$) else mem$ = "SELECT * FROM php WHERE code LIKE '%{%' AND seqNum > ";seqNum;" ORDER BY seqNum LIMIT 1" 'print mem$ #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() code$ = strRep$(code$,"{","") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum 'print mem$ #mem execute(mem$) end if end if mem$ = "SELECT * FROM php WHERE code LIKE '%}%' AND seqNum >= ";seqNum;" ORDER BY seqNum LIMIT 1" 'print mem$ #mem execute(mem$) rows = #mem ROWCOUNT() if rows > 0 then #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() code$ = strRep$(code$,"'","''") cmt = #row cmt() code$ = strRep$(code$,"}","WEND") mem$ = "UPDATE php SET code = '";code$;"' WHERE seqNum = ";seqNum 'print mem$ #mem execute(mem$) end if s = seqNum + 1 goto [nxtWhile] end if
' ------------------------------- ' file out in \public dir ' ------------------------------- fileOut$ = DefaultDir$ + strRep$(PHPfile$,".php",".bas") print "File Out:";fileOut$ OPEN fileOut$ for OUTPUT as #fo
mem$ = "SELECT * FROM php ORDER BY seqNum" #mem execute(mem$) WHILE #mem hasanswer() #row = #mem #nextrow() seqNum = #row seqNum() code$ = #row code$() cmt = #row cmt() if cmt > 0 then code$ = strRep$(code$,"//","'") if INSTR(code$,"\n") > 0 then code$ = strRep$(code$,"\n","chr$(13)") print using("########",seqNum);" |";code$ print #fo,code$ WEND close #fo print "-------------------------------------------" print "File Out:";fileOut$ wait
' -------------------------------- ' string replace rep str with ' -------------------------------- FUNCTION strRep$(str$,rep$,with$) ln = len(rep$) ln1 = ln - 1 i = 1 while i <= len(str$) if mid$(str$,i,ln) = rep$ then strRep$ = strRep$ + with$ i = i + ln1 else strRep$ = strRep$ + mid$(str$,i,1) end if i = i + 1 WEND END FUNCTION
' ----------------------------------------- ' strip junk ' ----------------------------------------- FUNCTION strip$(str$) strip$ = "" for i = 1 to len(str$) a$ = MID$(str$,i,1) a = ASC(a$) if a > 31 then if a < 127 then if a$ <> "'" then 'if a$ <> """" then strip$ = strip$ + a$ 'end if end if end if end if next i END FUNCTION
|
|
|
Post by Carl Gundel on Aug 26, 2019 21:18:12 GMT -5
Was trying to convert some PHP code to Liberty Basic and it was taking forever. So decided to write a program to help in the conversion. It worked good enough that I thought others may be interested. There are some things that there is no conversion. So depending on the PHP program it will convert anywhere from 80% to 95%. PHP uses underscore in their variables. You have the option to convert it to dot (.) or the next character to caps. So in PHP a variable of $seq_num can be converted to seq.num$ or seqNum$. Can you for curiosity's sake post a short example of a PHP program and the translation to LB?
|
|
|
Post by meerkat on Aug 27, 2019 7:54:02 GMT -5
Sur Nuf! PHP is usually used for web stuff. So cannot convert that. In most cases it may be better to use the converted coded in Run Basic. There are errors, but it's a good start for editing and cleanup. I'm working to clean up some errors. I requested the underscore in PHP variables to convert the next character to caps. Here is the conversion <? ' ------------------------------------------------------------------------------- *\ ' ** pipe hub exception maintenance: ' ** add change and delete pipe hub exceptions ' ** ' ** sr - sort request ' ** dt - detail -- change / delete etc ' ** li - list ' ** dr - delete record ' ** ro - request oorder -- orders sort request from sr ' ** '' \* ------------------------------------------------------------------------------- ' ----- first time only stuff if (!isset(pipe$)) THEN ' program initialization fprog$ = "xx" ' no from program tprog$ = "sr" ' to program start with sr sort request frqst$ = "" ' from request rqst$ = "" ' requested action for section dbRqst$ = "" ' pipe request order lpp$ = 10 ' lines pre page errMsg$(0) = "" END IF ' ---- set up constants ------------------- debug$ = 0 ar$ = "<p align="right">" ' align right ac$ = "<p align="center">" ' align center o$ = "<option>" ' drop down option os$ = "<option selected>" bf$ = "<b><font size="2" face="arial">" ' bold font bfg$ = "<b><font size="2" color="gold" face="arial">" ' bold font gold #cc9900 ih$ = "<input type="hidden" name=" it$ = "<input type="text" name=" ' input text ir$ = "<input type="radio" name=" ' input radio is$ = "<input type="submit" name=" ix$ = "<input type="reset" name=" mt$ = "<td> </td>" ' empty cell if (!isset(errNum$)) errNum$ = 0 if (!isset(lpp$)) lpp$ = 10 if (!isset(curPage$)) curPage$ = 0 if (!isset(userNum$)) userNum$ = 0 if (!isset(siteNum$)) siteNum$ = 0 if (!isset(tprog$)) tprog$ = "" if (!isset(prog$)) prog$ = "" if (!isset(dbRqst$)) dbRqst$ = "" if (!isset(spipeId$)) spipeId$ = 0 if (debug$) PRINT "0 fprog: fprog$ tprog: tprog$ rqst:rqst$ frqst frqst$ prog: prog|curPage:$curPage<br>"$ ' ------ check for ex - exit request if (rqst$ = "exit") THEN ' ----- get the hell out of here include("wiMain.php") exit END IF ' ----- hook up to database and bump user counts include "fnHookUp.php" include "fnBumpUser.php" x$ = bumpUser() fprog$ = tprog$ ' the from program is where ' the old program went to if (debug$) PRINT "1 fprog: fprog$ tprog: tprog$ rqst:rqst$ frqst frqst$ prog: prog|curPage:$curPage<br>"$ if (rqst$ = "help") tprog$ = "hp" ' help me! if (fprog$ = "sr") THEN curPage$ = 1 if (rqst$ = "add") tprog$ = "dt" ' add an pipe else request$ = rqstOrder() if (debug$) PRINT "rqst: rqst|dbRqst:$ dbRqst<br>"$ if (rqst$ = "list") tprog$ = "li" END IF ' ----- from dt pipeHub detail if (fprog$ = "dt") THEN if (debug$) PRINT "dt pipe spipeId spipeId<br>"$ if (rqst$ = "add") { request$ = acDetail("a") ' add the sucker if (errNum$ = 0) { curPage--$ tprog$ = "li" END IF } if (rqst$ = "quit") THEN curPage--$ tprog$ = "li" END IF if (rqst$ = "chg") THEN request$ = acDetail("c") ' change the sucker if (errNum$ = 0) { curPage--$ tprog$ = "li" END IF } if (rqst$ = "del") THEN request$ = delRecord() ' delete the sucker curPage--$ tprog$ = "li" END IF if (rqst$ = "exit.") tprog$ = "sr" if (rqst$ = "cancel") THEN wrnNum$ = 1 wrnMsg$(wrnNum$) = "canceled per request" tprog$ = "li" curPage--$ END IF if (!dbRqst$) rqstOrder() } ' ---- from li list pipe if (fprog$ = "li") THEN if (rqst$ = "add") tprog$ = "dt" ' --- add request$ = acDetail() add pipe if ((rqst$ = "chg") || (rqst$ = "look")) { if (empty(spipeId$)) { curPage--$ errNum$ = 1 errMsg$(errNum$) = " please select a pipe hub. thank you and have a nice day" else tprog$ = "dt" ' pipe detail END IF if (rqst$ = "del") THEN if (empty(spipeId$)) { curPage--$ errNum$ = 1 errMsg$(errNum$) = " please select a pipe hub to delete. thank you and have a nice day" else tprog$ = "dt" ' pipe detail END IF if (rqst$ = "sort") tprog$ = "sr" if (rqst$ = "exit.") tprog$ = "sr" } if (debug$) PRINT "2 fprog: fprog$ tprog: tprog$ rqst:rqst$ frqst frqst$ prog: prog|curPage:$curPage<br>"$ if (tprog$ = "sr") prog$ = "sortRequest" if (tprog$ = "li") prog$ = "listPipe" if (tprog$ = "dr") prog$ = "delRecord" if (tprog$ = "dt") prog$ = "pipeDetail" frqst$ = rqst$ ' the frin reqest is the current request if (debug$) PRINT "3 fprog: fprog$ tprog: tprog$ rqst:rqst$ frqst frqst$ prog: prog|curPage:$curPage<br>"$ ' request$ = htmlHeader() request$ = prog$() request$ = footer() exit ' ======================================== *\ ' ** functions '' \* ======================================== ' ---------------------------------------------------- *\ ' ** header '' \* ---------------------------------------------------- function htmlHeader() THEN global ih$ fprog$ tprog$ frqst$ ac$ dbRqst$ winery$ siteNum$ userNum$ errNum$ errMsg$ wrnNum$ wrnMsg$ lpp$ curPage$ totRows$ totPages$ fHub$ fPort$ spipeId$ PRINT "<html><head><title>pipe hub exceptions</title> <style type="text/css"> <!-- body {font-family:arialfont-size:x-smallEND IF --> </style> </head>" PRINT "<body bgcolor="#e0d5cd">" PRINT "<form method="post" action="wiPiph.php">" PRINT "ih$ "dbRqst" value=" + """ + stripslashes(dbRqst$) + "">" PRINT "ih$ "pipe" value="pipe">" PRINT "ih$ "fprog" value="fprog">"$ PRINT "ih$ "tprog" value="tprog">"$ PRINT "ih$ "frqst" value="frqst">"$ ' PRINT "ih$ "spipeId" value="spipeId">"$ PRINT "ih$ "lpp" value="lpp">"$ PRINT "ih$ "curPage" value=curPage>"$ PRINT "ih$ "totRows" value=totRows>"$ PRINT "ih$ "totPages" value=totPages>"$ PRINT "<center>" ' --------------- messages ---------------------------- if ((errNum$ > 0) or (wrnNum$ > 0)) include "fnErrMsg.php" ' ---------------------------------------------------- *\ ' ** footer '' \* ---------------------------------------------------- function footer() THEN PRINT "</form></body></html>" END IF ' ---------------------------------------------------- *\ ' ** sr display sort and request screen '' \* ---------------------------------------------------- function sortRequest() { global linkId$ help$ include "wiPiphSr.htm" } ' end selection screen ' --------------------------------------------- *\ ' ** ro function for ordering selection ' ** creaes the database selection query (dbRqst) ' ** based on user request '' \* --------------------------------------------- function rqstOrder() { global debug$ sort1$ sort2$ begHub$ endHub$ begPort$ endPort$ begNumHoses$ endNumHoses$ pipeType$ clip$ siteNum$ dbRqst$ wa$ if (debug$) PRINT "we got us a sort<br>" include "fnChkField.php" dbRqst$ = " select * from pipeHub where pipeHub.siteNum = siteNum$ " wa$ = " and " dbRqst$ .= chkField("begHub" "pipeHub.fHub" ">=" """) dbRqst$ .= chkField("endHub" "pipeHub.fHub" "<=" """) dbRqst$ .= chkField("begPort" "pipeHub.fPort" ">=" "") dbRqst$ .= chkField("endPort" "pipeHub.fPort" "<=" "") dbRqst$ .= chkField("begNumHoses" "pipeHub.numHoses" ">=" "") dbRqst$ .= chkField("endNumHoses" "pipeHub.numHoses" "<=" "") if (sort1$) dbRqst$ .= " order by sort1$ sort2$ " if (debug$) PRINT "in ro dbRqst: dbRqst<br>"$ } ' ------------------------------------------- *\ ' ** ai add/change pipe user requested ** '' \* ------------------------------------------- function acDetail(ac$) THEN global debug$ errNum$ errMsg$ curPage$ wrnNum$ wrnMsg$ siteNum$ spipeId$ fHub$ fPort$ linkId$ global fHub$ fPort$ tHub$ tPort$ numHoses$ clip$ @list (hub$ port$ seqNum$) = @explode("|" spipeId$) if (debug$) PRINT "1 in acDetail site#: siteNum$ spipe# spipeId$ hub: hub|port:$port|seq:$seqNum<br>"$ fHub$ = strtoupper(trim(fHub$)) fPort$ = trim(fPort$) tHub$ = strtoupper(trim(tHub$)) tPort$ = trim(tPort$) fPort$ += 0 tPort$ += 0 numHoses$ += 0 clip$ = strtoupper(trim(clip$)) if ((fHub$ = tHub$) AND (fPort$ = tPort$)) { errNum++$ errMsg$(errNum$) = "from and to are the same" END IF sql$ = " select * from pipe where pipe.siteNum = siteNum$ and pipe.fHub = "fHub"$ limit 1" result$ = @mysqlQuery(sql$ linkId$) numRows$ = @mysqlNumRows(result$) if (numRows$ < 1) THEN errNum++$ errMsg$(errNum$) = "invalid hub: fHub"$ END IF sql$ = " select * from pipe where pipe.siteNum = siteNum$ and pipe.tHub = "tHub"$ limit 1" result$ = @mysqlQuery(sql$ linkId$) numRows$ = @mysqlNumRows(result$) if (numRows$ < 1) THEN errNum++$ errMsg$(errNum$) = "invalid hub: tHub"$ END IF if (debug$) PRINT "the number on pipe file numRows<br>"$ if (ac$ = "c") THEN sql$ = " select * from pipeHub where pipeHub.siteNum = siteNum$ and pipeHub.seqNum = seqNum$ limit 1" result$ = @mysqlQuery(sql$ linkId$) qttt$ = @mysqlFetchArray(result$) tttHub$ = @qttt$("tHub") tttPort$ = @qttt$("tPort") if (debug$) PRINT "find ttt side|ttthub:tttHub|tttport:$tttPort|$ result:result$ |sql:sql<br>"$ sql$ = " select * from pipeHub where pipeHub.siteNum = siteNum$ and pipeHub.fHub = "tttHub"$ and pipeHub.fPort = tttPort$ limit 1" result$ = @mysqlQuery(sql$ linkId$) qfff$ = @mysqlFetchArray(result$) tSeqNum$ = @qfff$("seqNum") if (debug$) PRINT "find t seq|tSeq:tSeqNum|result:$result$ |sql:sql<br>"$ sql$ = " delete from pipeHub where pipeHub.siteNum = siteNum$ and (pipeHub.seqNum = seqNum$ or pipeHub.seqNum = tSeqNum$)" result$ = @mysqlQuery(sql$ linkId$) if (debug$) PRINT "delete result:result$ |sql:sql<br>"$ ac$ = "a" END IF if (ac$ = "a") THEN if (debug$) PRINT "in ac add fhub:fHub$ fport:fPort$ thub:tHub$ tport:tPort$ numHoses:numHoses$ st:clip<br>"$ if (fHub$ = "") { errNum++$ errMsg$(errNum$) = "please enter a from hub" END IF if (tHub$ = "") THEN errNum++$ errMsg$(errNum$) = "please enter a to hub" END IF if (fPort$ < 1) THEN errNum++$ errMsg$(errNum$) = "please enter a from port" END IF if (tPort$ < 1) THEN errNum++$ errMsg$(errNum$) = "please enter a to port" END IF if (errNum$ = 0) THEN sql$ = " select * from pipeHub where pipeHub.siteNum = siteNum$ and pipeHub.fHub = "fHub"$ and pipeHub.fPort = fPort$ or (pipeHub.siteNum = siteNum$ and pipeHub.fHub = "tHub"$ and pipeHub.tPort = tPort$) or (pipeHub.siteNum = siteNum$ and pipeHub.tHub = "fHub"$ and pipeHub.tPort = fPort$) or (pipeHub.siteNum = siteNum$ and pipeHub.fHub = "tHub"$ and pipeHub.tPort = tPort$) limit 1" result$ = @mysqlQuery(sql$ linkId$) while(qf$ = mysqlFetchArray(result$)) { ffHub$ = qf$("fHub") ffPort$ = qf$("fPort") ttHub$ = qf$("tHub") ttPort$ = qf$("tPort") lnumHoses$ = qf$("numHoses") errNum++$ errMsg$(errNum$) = "can"t add - already on file at from:ffHub-$ffPort$ to:ttHub-$ttPort$ numHoses:lnumHoses"$ END IF } if (errNum$ = 0) THEN sql$ = " insert into pipeHub set siteNum = siteNum$ fHub = "fHub"$ fPort = fPort$ tHub = "tHub"$ tPort = tPort$ numHoses = numHoses$ clip = "clip""$ result$ = mysqlQuery(sql$ linkId$) sql$ = " insert into pipeHub set siteNum = siteNum$ tHub = "fHub"$ tPort = fPort$ fHub = "tHub"$ fPort = tPort$ numHoses = numHoses$ clip = "clip""$ result$ = mysqlQuery(sql$ linkId$) END IF } if (errNum$ = 0) THEN if (ac$ = "a") { if (result$) { wrnNum++$ wrnMsg$(wrnNum$) = "added exception fHub$ fPort$ -> tHub$ tPort"$ END IF } if (ac$ = "c") THEN wrnNum++$ wrnMsg$(wrnNum$) = "changed exception fHub$ fPort$ -> tHub$ tPort"$ ' global curPage$ ' curPage--$ END IF } spipeId$ = "" } ' ------------------------------------------- *\ ' ** dr delete pipe requested ** '' \* ------------------------------------------- function delRecord() { global debug$ errNum$ errMsg$ wrnNum$ wrnMsg$ spipeId$ siteNum$ linkId$ errNum$ = 0 if (debug$) PRINT "in dr delete spipe#: spipeId$ site#: siteNum<br>"$ list (hub$ port$ seqNum$) = @explode("|" spipeId$) ' ' dbQuery$ = ' "select * ' from pipeHub ' where pipeHub.siteNum = siteNum$ ' and pipeHub.fHub = "hub"$ ' and pipeHub.fPort = port$ limit 1" ' ' result$ = mysqlQuery(dbQuery$ ' linkId$) ' if (result$) ' THEN ' while(queryData$ = mysqlFetchArray(result$)) ' { ' wpoNum$ = queryData$("wpoNum") ' legNum$ = queryData$("legNum") ' storageId$ = queryData$("storageId") ' errNum++$ ' errMsg$(errNum$) = " pipe: spipeId$ cannot be deleted.<br>" ' + " in use at wpo:wpoNum$ leg:legNum$ storage:storageId$ <br>" ' END IF ' } '' if (errNum$ = 0) THEN sql$ = "delete from pipeHub where pipeHub.siteNum = siteNum$ and pipeHub.fHub = "hub"$ and pipeHub.fPort = port$ or (pipeHub.tHub = "hub"$ and pipeHub.tPort = port$)" result$ = mysqlQuery(sql$ linkId$) if (debug$) PRINT "delete result:result$ |sql:sql<br>"$ if (result$) { wrnNum++$ wrnMsg$(wrnNum$) = "pipe: hub$ port$ deleted<br>" END IF } } ' --------- end delete pipe ' -------------------------------------------- *\ ' ** li list pipe selection screen ** '' \* -------------------------------------------- function listPipe() { global debug$ help$ linkId$ dbRqst$ siteNum$ userNum$ totRows$ totPages$ curPage$ lpp$ bfg$ ac$ ar$ ih$ is$ ix$ mt$ o$ ir$ os$ bf1$ x$ = htmlHeader() ' ------------------------ listing header ---------------- PRINT "<table border="1" cellpadding="0" cellspacing="0">" PRINT "<tr bgcolor="#5070a0">" PRINT "<td colspan="8"> ac$ pipe hub exceptions</td></tr>" PRINT "<tr bgcolor="#5070a0">" PRINT "<td rowspan="2"> ac$ s<br>e<br>l </td>" PRINT "<td rowspan="2"> ac$ seq </td>" PRINT "<td colspan="2"> ac$ from </td>" PRINT "<td colspan="2"> ac$ to </td>" PRINT "<td rowspan="2"> ac$ num<br>hose </td>" PRINT "<td rowspan="2"> ac$ clip </td></tr>" PRINT "<tr bgcolor="#5070a0">" PRINT "<td> ac$ hub </td>" PRINT "<td> ac$ port </td>" PRINT "<td> ac$ hub </td>" PRINT "<td> ac$ port </td></tr>" ' ---------------- list info ------------------ line$ = 0 ' parm$ = @bumpUser(parm$) dbRqst$ = stripslashes(dbRqst$) if (debug$) PRINT "dbRqst: dbRqst|curPage:$curPage<br>"$ if (!totRows$) THEN result$ = mysqlQuery(dbRqst$ linkId$) totRows$ = mysqlNumRows(result$) END IF if (curPage$ < 1) curPage$ = 1 start$ = (curPage$ - 1) * lpp$ dbQuery1$ = dbRqst$ + " limit start$ lpp"$ if (debug$) PRINT "selection1: dbQuery1|totRows:$totRows<br>"$ result1$ = mysqlQuery(dbQuery1$ linkId$) totPages$ = ceil(totRows$ / lpp$) '-- and number of pages at lpp$ per page if (debug$) PRINT "result1: result1|totRows:$totRows:$totPages<br>"$ while(queryData$ = mysqlFetchArray(result1$)) THEN seqNum$ = queryData$("seqNum") fHub$ = queryData$("fHub") fPort$ = queryData$("fPort") tHub$ = queryData$("tHub") tPort$ = queryData$("tPort") numHoses$ = queryData$("numHoses") clip$ = queryData$("clip") if (line$ & 1) PRINT "<tr bgcolor="#ffffcc">" else PRINT "<tr>" spipeId$ = fHub$ + "|" + fPort$ + "|" + seqNum$ PRINT "<td> ac$ ir$ "spipeId" value=spipeId></td>"$ PRINT "<td> ar$ seqNum$ </td>" PRINT "<td> ar$ fHub$ </td>" PRINT "<td> ar$ fPort$ </td>" PRINT "<td> ar$ tHub$ </td>" PRINT "<td> ar$ tPort$ </td>" PRINT "<td> ar$ numHoses$ </td>" PRINT "<td> ac$ clip$ </td>" PRINT "</tr>" line++$ END IF PRINT "</tr></table>" ' -------------- buttons -------------------------- program$ = "wiPiph.php" include "inButtonsLiAll.php" PRINT "</form></body></html>" } ' end list pipe screen -------------------------- ' ------------------------------------------------------ *\ ' ** pipe detail screen '' \* ------------------------------------------------------ function pipeDetail() { global debug$ errNum$ errMsg$ wrnNum$ wrnMsg$ spipeId$ rqst$ fprog$ help$ siteNum$ winery$ userNum$ linkId$ mt$ ih$ global fHub$ fPort$ tHub$ tPort$ numHoses$ clip$ if (debug$) PRINT "in dt rqst: rqst$ spipeId# spipeId$ site:siteNum<br>"$ ' ----------- first time ------------- if (fprog$ <> "dt") THEN @list (hub$ port$) = explode("|" spipeId$) sql$ = " select * from pipeHub where pipeHub.siteNum = siteNum$ and pipeHub.fHub = "hub"$ and pipeHub.fPort = port$ limit 1" result$ = mysqlQuery(sql$ linkId$) queryData$ = @mysqlFetchArray(result$) fHub$ = queryData$("fHub") fPort$ = queryData$("fPort") tHub$ = queryData$("tHub") tPort$ = queryData$("tPort") numHoses$ = queryData$("numHoses") clip$ = queryData$("clip") if (debug$) PRINT "result|$sql<br>"$ END IF x$ = htmlHeader() PRINT "<table border="1" cellpadding="0" cellspacing="0" bgcolor="#edeae0">" PRINT "<tr><td colspan="4" bgcolor="#d0bfb3"><p align="center"><b>pipe hub exceptions</b></td></tr>" PRINT "ih$ "spipeId" value="spipeId">"$ if (rqst$ = "add") THEN PRINT "<tr><td><p align="right"><b>from hub</b></td>" PRINT "<td><input type="text" name="fHub" size="3" maxlength="3" value="fHub"></td>"$ PRINT "<td><p align="right"><b>port</b></td>" PRINT "<td><input type="text" name="fPort" size="3" maxlength="3" value="fPort"></td>"$ END IF else { PRINT "<tr><td><p align="right"><b>from hub</b></td>" PRINT "<td><b>fHub</td>"$ PRINT "ih$ "fHub" value="fHub">"$ PRINT "<td><p align="right"><b>port</b></td>" PRINT "<td><b>fPort</td></tr>"$ PRINT "ih$ "fPort" value=fPort"$ } PRINT "<tr><td><p align="right"><b>to hub</b></td>" PRINT "<td><input type="text" name="tHub" size="3" maxlength="3" value="tHub"></td>"$ PRINT "<td><p align="right"><b>port</b></td>" PRINT "<td><input type="text" name="tPort" size="3" maxlength="3" value="tPort"></td></tr>"$ PRINT "<tr><td><p align="right"><b>num hoses</b></td>" PRINT "<td colspan=3><input type="text" name="numHoses" size="5" maxlength="5" value="numHoses"></td>"$ PRINT "<tr><td><p align="right"><b>clip</b></td>" PRINT "<td colspan=3><input type="text" name="clip" size="3" maxlength="3" value="clip"></td>"$ PRINT "</tr>" PRINT "</table>" include "inButtonsDt.php" ' PRINT "</center></form></body></html>" } ' ------- end detail screen -------------- ?>
Here is the source PHP <? /* ------------------------------------------------------------------------------- *\ ** Add Change and Delete pipe hub exceptions ** ** SR - Sort Request ** DT - detail -- change / delete etc ** LI - List ** DR - Delete Record ** RO - Request Oorder -- orders sort request from SR ** \* ------------------------------------------------------------------------------- */
// ----- First time only stuff if (!isset($pipe)) { // program initialization $fprog = 'XX'; // No From program $tprog = 'SR'; // to program start with SR sort request $frqst = ''; // from request $rqst = ''; // requested action for section $db_rqst = ''; // pipe request order $lpp = 10; // lines pre page $err_msg[0] = ''; }
// ---- set up constants ------------------- $debug = 0; $ar = "<P ALIGN='RIGHT'>"; // Align right $ac = "<P ALIGN='CENTER'>"; // Align center $o = "<OPTION>"; // Drop down option $os = "<OPTION SELECTED>"; $bf = "<B><FONT SIZE='2' FACE='Arial'>"; // Bold font $bfg = "<B><FONT SIZE='2' COLOR='gold' FACE='Arial'>"; // Bold font gold #CC9900 $ih = "<INPUT TYPE='HIDDEN' NAME="; $it = "<INPUT TYPE='TEXT' NAME="; // Input text $ir = "<INPUT TYPE='RADIO' NAME="; // Input Radio $is = "<INPUT TYPE='SUBMIT' NAME="; $ix = "<INPUT TYPE='RESET' NAME="; $mt = "<TD> </TD>"; // Empty cell
if (!isset($err_num)) $err_num = 0; if (!isset($lpp)) $lpp = 10; if (!isset($cur_page)) $cur_page = 0; if (!isset($user_num)) $user_num = 0; if (!isset($site_num)) $site_num = 0; if (!isset($tprog)) $tprog = ''; if (!isset($prog)) $prog = ''; if (!isset($db_rqst)) $db_rqst = ''; if (!isset($spipe_id)) $spipe_id = 0;
if ($debug) echo "0 fprog: $fprog tprog: $tprog rqst:$rqst frqst $frqst prog: $prog|cur_page:$cur_page<BR>";
// ------ check for EX - Exit request if ($rqst == 'Exit') { // ----- Get the hell out of here include('wi_main.php'); exit; }
// ----- hook up to database and bump user counts include 'fn_hook_up.php'; include 'fn_bump_user.php'; $x = bump_user();
$fprog = $tprog; // the from program is where // the old program went to
if ($debug) echo "1 fprog: $fprog tprog: $tprog rqst:$rqst frqst $frqst prog: $prog|cur_page:$cur_page<BR>"; if ($rqst == 'Help') $tprog = 'HP'; // Help Me!
if ($fprog == "SR") { $cur_page = 1; if ($rqst == 'Add') $tprog = 'DT'; // add an pipe else $request = rqst_order(); if ($debug) echo "rqst: $rqst|db_rqst: $db_rqst<BR>"; if ($rqst == 'List') $tprog = 'LI'; }
// ----- From DT pipe_hub detail if ($fprog == 'DT') { if ($debug) echo "DT pipe spipe_id $spipe_id<BR>"; if ($rqst == 'Add') { $request = ac_detail('A'); // add the sucker if ($err_num == 0) { $cur_page--; $tprog = 'LI'; } } if ($rqst == 'Quit') { $cur_page--; $tprog = 'LI'; } if ($rqst == 'Chg') { $request = ac_detail('C'); // change the sucker if ($err_num == 0) { $cur_page--; $tprog = 'LI'; } } if ($rqst == 'Del') { $request = del_record(); // delete the sucker $cur_page--; $tprog = 'LI'; } if ($rqst == 'Exit.') $tprog = 'SR'; if ($rqst == 'Cancel') { $wrn_num = 1; $wrn_msg[$wrn_num] = "Canceled per request"; $tprog = 'LI'; $cur_page--; } if (!$db_rqst) rqst_order(); }
// ---- From LI List pipe if ($fprog == 'LI') { if ($rqst == 'Add') $tprog = 'DT'; // --- add $request = ac_detail(); add pipe if (($rqst == 'Chg') || ($rqst == 'Look')) { if (empty($spipe_id)) { $cur_page--; $err_num = 1; $err_msg[$err_num] = " Please select a Pipe Hub. Thank you and have a nice day"; } else $tprog = 'DT'; // pipe detail } if ($rqst == 'Del') { if (empty($spipe_id)) { $cur_page--; $err_num = 1; $err_msg[$err_num] = " Please select a Pipe Hub to Delete. Thank you and have a nice day"; } else $tprog = 'DT'; // pipe detail } if ($rqst == 'Sort') $tprog = 'SR'; if ($rqst == 'Exit.') $tprog = 'SR'; } if ($debug) echo "2 fprog: $fprog tprog: $tprog rqst:$rqst frqst $frqst prog: $prog|cur_page:$cur_page<BR>";
if ($tprog == 'SR') $prog = 'sort_request'; if ($tprog == 'LI') $prog = 'list_pipe'; if ($tprog == 'DR') $prog = 'del_record'; if ($tprog == 'DT') $prog = 'pipe_detail';
$frqst = $rqst; // The frin reqest is the current request
if ($debug) echo "3 fprog: $fprog tprog: $tprog rqst:$rqst frqst $frqst prog: $prog|cur_page:$cur_page<BR>";
// $request = html_header(); $request = $prog(); $request = footer(); exit;
/* =============================================================================== *\ ** FUNCTIONS \* =============================================================================== */
/* ---------------------------------------------------- *\ ** Header \* ---------------------------------------------------- */ function html_header() { global $ih, $fprog, $tprog, $frqst, $ac, $db_rqst, $winery, $site_num, $user_num, $err_num, $err_msg, $wrn_num, $wrn_msg, $lpp, $cur_page, $tot_rows, $tot_pages, $f_hub, $f_port, $spipe_id;
echo "<HTML><HEAD><TITLE>Pipe Hub Exceptions</TITLE> <STYLE TYPE='text/css'> <!-- BODY {Font-Family:arial;Font-Size:X-small} --> </STYLE> </HEAD>";
echo "<BODY BGCOLOR='#E0D5CD'>"; echo "<FORM METHOD='POST' ACTION='wi_piph.php'>"; echo "$ih 'db_rqst' VALUE=" . '"' . stripslashes($db_rqst) . '">'; echo "$ih 'pipe' VALUE='pipe'>"; echo "$ih 'fprog' VALUE='$fprog'>"; echo "$ih 'tprog' VALUE='$tprog'>"; echo "$ih 'frqst' VALUE='$frqst'>"; // echo "$ih 'spipe_id' VALUE='$spipe_id'>"; echo "$ih 'lpp' VALUE='$lpp'>"; echo "$ih 'cur_page' VALUE=$cur_page>"; echo "$ih 'tot_rows' VALUE=$tot_rows>"; echo "$ih 'tot_pages' VALUE=$tot_pages>";
echo "<CENTER>";
// --------------- MESSAGES ---------------------------- if (($err_num > 0) or ($wrn_num > 0)) include 'fn_err_msg.php';
/* ---------------------------------------------------- *\ ** Footer \* ---------------------------------------------------- */ function footer() { echo "</FORM></BODY></HTML>"; } /* ---------------------------------------------------- *\ ** SR Display sort and request screen \* ---------------------------------------------------- */ function sort_request() { global $link_id, $help; include 'wi_piph_sr.htm'; } // end selection screen
/* --------------------------------------------- *\ ** RO Function for ordering selection ** Creaes the database selection query (db_rqst) ** based on user request \* --------------------------------------------- */ function rqst_order() { global $debug, $sort1, $sort2, $beg_hub, $end_hub, $beg_port, $end_port, $beg_num_hoses, $end_num_hoses, $pipe_type, $clip, $site_num, $db_rqst, $wa;
if ($debug) echo "We got us a sort<BR>";
include 'fn_chk_field.php';
$db_rqst = " SELECT * FROM pipe_hub WHERE pipe_hub.site_num = $site_num "; $wa = " AND "; $db_rqst .= chk_field("beg_hub", "pipe_hub.f_hub", ">=", "'"); $db_rqst .= chk_field("end_hub", "pipe_hub.f_hub", "<=", "'"); $db_rqst .= chk_field("beg_port", "pipe_hub.f_port", ">=", ""); $db_rqst .= chk_field("end_port", "pipe_hub.f_port", "<=", ""); $db_rqst .= chk_field("beg_num_hoses", "pipe_hub.num_hoses", ">=", ""); $db_rqst .= chk_field("end_num_hoses", "pipe_hub.num_hoses", "<=", "");
if ($sort1) $db_rqst .= " ORDER BY $sort1 , $sort2 ";
if ($debug) echo "IN RO db_rqst: $db_rqst<BR>"; }
/* ------------------------------------------- *\ ** AI add/change pipe user requested ** \* ------------------------------------------- */ function ac_detail($ac) { global $debug, $err_num, $err_msg, $cur_page, $wrn_num, $wrn_msg, $site_num, $spipe_id, $f_hub, $f_port, $link_id; global $f_hub, $f_port, $t_hub, $t_port, $num_hoses, $clip;
@list ($hub, $port,$seq_num) = @explode("|",$spipe_id); if ($debug) echo "1 IN ac_detail Site#: $site_num Spipe# $spipe_id hub: $hub|port:$port|seq:$seq_num<BR>";
$f_hub = strtoupper(trim($f_hub)); $f_port = trim($f_port); $t_hub = strtoupper(trim($t_hub)); $t_port = trim($t_port); $f_port += 0; $t_port += 0; $num_hoses += 0; $clip = strtoupper(trim($clip));
if (($f_hub == $t_hub) && ($f_port == $t_port)) { $err_num++; $err_msg[$err_num] = "From and To are the same"; }
$sql = " SELECT * FROM pipe WHERE pipe.site_num = $site_num AND pipe.f_hub = '$f_hub' LIMIT 1"; $result = @mysql_query($sql, $link_id); $num_rows = @mysql_num_rows($result); if ($num_rows < 1) { $err_num++; $err_msg[$err_num] = "Invalid Hub: $f_hub"; } $sql = " SELECT * FROM pipe WHERE pipe.site_num = $site_num AND pipe.t_hub = '$t_hub' LIMIT 1"; $result = @mysql_query($sql, $link_id); $num_rows = @mysql_num_rows($result); if ($num_rows < 1) { $err_num++; $err_msg[$err_num] = "Invalid Hub: $t_hub"; } if ($debug) echo "The number on pipe file $num_rows<BR>"; if ($ac == 'C') { $sql = " SELECT * FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND pipe_hub.seq_num = $seq_num LIMIT 1"; $result = @mysql_query($sql, $link_id); $qttt = @mysql_fetch_array($result); $ttt_hub = @$qttt["t_hub"]; $ttt_port = @$qttt["t_port"]; if ($debug) echo "Find TTT side|ttthub:$ttt_hub|tttPort:$ttt_port| result:$result |sql:$sql<BR>"; $sql = " SELECT * FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$ttt_hub' AND pipe_hub.f_port = $ttt_port LIMIT 1"; $result = @mysql_query($sql, $link_id); $qfff = @mysql_fetch_array($result); $t_seq_num = @$qfff["seq_num"]; if ($debug) echo "Find T seq|t_seq:$t_seq_num|result:$result |sql:$sql<BR>"; $sql = " DELETE FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND (pipe_hub.seq_num = $seq_num OR pipe_hub.seq_num = $t_seq_num)"; $result = @mysql_query($sql, $link_id);
if ($debug) echo "DELETE result:$result |sql:$sql<BR>"; $ac = 'A'; }
if ($ac == 'A') {
if ($debug) echo "IN AC ADD fhub:$f_hub fport:$f_port thub:$t_hub tport:$t_port num_hoses:$num_hoses st:$clip<BR>";
if ($f_hub == '') { $err_num++; $err_msg[$err_num] = "Please enter a From Hub"; } if ($t_hub == '') { $err_num++; $err_msg[$err_num] = "Please enter a To Hub"; }
if ($f_port < 1) { $err_num++; $err_msg[$err_num] = "Please enter a From Port"; } if ($t_port < 1) { $err_num++; $err_msg[$err_num] = "Please enter a To Port"; }
if ($err_num == 0) { $sql = " SELECT * FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$f_hub' AND pipe_hub.f_port = $f_port OR (pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$t_hub' AND pipe_hub.t_port = $t_port) OR (pipe_hub.site_num = $site_num AND pipe_hub.t_hub = '$f_hub' AND pipe_hub.t_port = $f_port) OR (pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$t_hub' AND pipe_hub.t_port = $t_port) LIMIT 1"; $result = @mysql_query($sql, $link_id); while($qf = mysql_fetch_array($result)) { $ff_hub = $qf["f_hub"]; $ff_port = $qf["f_port"]; $tt_hub = $qf["t_hub"]; $tt_port = $qf["t_port"]; $lnum_hoses = $qf["num_hoses"]; $err_num++; $err_msg[$err_num] = "Can't add - already on file at From:$ff_hub-$ff_port To:$tt_hub-$tt_port num_hoses:$lnum_hoses"; } }
if ($err_num == 0) { $sql = " INSERT INTO pipe_hub SET site_num = $site_num, f_hub = '$f_hub', f_port = $f_port, t_hub = '$t_hub', t_port = $t_port, num_hoses = $num_hoses, clip = '$clip'"; $result = mysql_query($sql, $link_id); $sql = " INSERT INTO pipe_hub SET site_num = $site_num, t_hub = '$f_hub', t_port = $f_port, f_hub = '$t_hub', f_port = $t_port, num_hoses = $num_hoses, clip = '$clip'"; $result = mysql_query($sql, $link_id); } } if ($err_num == 0) { if ($ac == 'A') { if ($result) { $wrn_num++; $wrn_msg[$wrn_num] = "Added Exception $f_hub $f_port -> $t_hub $t_port"; } } if ($ac == 'C') { $wrn_num++; $wrn_msg[$wrn_num] = "Changed Exception $f_hub $f_port -> $t_hub $t_port"; // global $cur_page; // $cur_page--; } } $spipe_id = ''; } /* ------------------------------------------- *\ ** DR delete pipe requested ** \* ------------------------------------------- */ function del_record() { global $debug, $err_num, $err_msg, $wrn_num, $wrn_msg, $spipe_id, $site_num, $link_id;
$err_num = 0; if ($debug) echo "IN DR Delete spipe#: $spipe_id Site#: $site_num<BR>";
list ($hub,$port,$seq_num) = @explode("|",$spipe_id); /* $db_query = "SELECT * FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$hub' AND pipe_hub.f_port = $port LIMIT 1";
$result = mysql_query($db_query, $link_id); if ($result) { while($query_data = mysql_fetch_array($result)) { $wpo_num = $query_data["wpo_num"]; $leg_num = $query_data["leg_num"]; $storage_id = $query_data["storage_id"]; $err_num++; $err_msg[$err_num] = " pipe: $spipe_id Cannot be Deleted.<BR>" . " In use at WPO:$wpo_num LEG:$leg_num Storage:$storage_id <BR>"; } } */ if ($err_num == 0) { $sql = "DELETE FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$hub' AND pipe_hub.f_port = $port OR (pipe_hub.t_hub = '$hub' AND pipe_hub.t_port = $port)"; $result = mysql_query($sql, $link_id); if ($debug) echo "Delete result:$result |sql:$sql<BR>"; if ($result) { $wrn_num++; $wrn_msg[$wrn_num] = "Pipe: $hub $port Deleted<BR>"; } } } // --------- End delete pipe /* -------------------------------------------- *\ ** LI List pipe selection screen ** \* -------------------------------------------- */ function list_pipe() { global $debug, $help, $link_id, $db_rqst, $site_num, $user_num, $tot_rows, $tot_pages, $cur_page, $lpp, $bfg, $ac, $ar, $ih, $is, $ix, $mt, $o, $ir, $os,$bf1;
$x = html_header();
// ------------------------ Listing header ---------------- echo "<TABLE BORDER='1' CELLPADDING='0' CELLSPACING='0'>"; echo "<TR BGCOLOR='#5070A0'>"; echo "<TD COLSPAN='8'> $ac Pipe Hub Exceptions</TD></TR>"; echo "<TR BGCOLOR='#5070A0'>"; echo "<TD ROWSPAN='2'> $ac S<BR>e<BR>l </TD>"; echo "<TD ROWSPAN='2'> $ac Seq </TD>"; echo "<TD COLSPAN='2'> $ac From </TD>"; echo "<TD COLSPAN='2'> $ac To </TD>"; echo "<TD ROWSPAN='2'> $ac Num<BR>Hose </TD>"; echo "<TD ROWSPAN='2'> $ac Clip </TD></TR>";
echo "<TR BGCOLOR='#5070A0'>"; echo "<TD> $ac Hub </TD>"; echo "<TD> $ac Port </TD>"; echo "<TD> $ac Hub </TD>"; echo "<TD> $ac Port </TD></TR>";
// ---------------- list info ------------------ $line = 0;
// $parm = @bump_user($parm); $db_rqst = stripslashes($db_rqst); if ($debug) echo "db_rqst: $db_rqst|cur_page:$cur_page<BR>";
if (!$tot_rows) { $result = mysql_query($db_rqst, $link_id); $tot_rows = mysql_num_rows($result); }
if ($cur_page < 1) $cur_page = 1; $start = ($cur_page - 1) * $lpp; $db_query1 = $db_rqst . " LIMIT $start,$lpp"; if ($debug) echo "Selection1: $db_query1|tot_rows:$tot_rows<BR>"; $result1 = mysql_query($db_query1, $link_id);
$tot_pages = ceil($tot_rows / $lpp); //-- and number of pages at $lpp per page
if ($debug) echo "Result1: $result1|tot_rows:$tot_rows:$tot_pages<BR>"; while($query_data = mysql_fetch_array($result1)) { $seq_num = $query_data["seq_num"]; $f_hub = $query_data["f_hub"]; $f_port = $query_data["f_port"]; $t_hub = $query_data["t_hub"]; $t_port = $query_data["t_port"]; $num_hoses = $query_data["num_hoses"]; $clip = $query_data["clip"];
if ($line & 1) echo "<TR BGCOLOR='#FFFFCC'>"; else echo "<TR>"; $spipe_id = $f_hub . "|" . $f_port . "|" . $seq_num; echo "<TD> $ac $ir 'spipe_id' VALUE=$spipe_id></TD>"; echo "<TD> $ar $seq_num </TD>"; echo "<TD> $ar $f_hub </TD>"; echo "<TD> $ar $f_port </TD>"; echo "<TD> $ar $t_hub </TD>"; echo "<TD> $ar $t_port </TD>"; echo "<TD> $ar $num_hoses </TD>"; echo "<TD> $ac $clip </TD>"; echo "</TR>"; $line++; } echo "</TR></table>"; // -------------- Buttons -------------------------- $program = 'wi_piph.php'; include 'in_buttons_li_all.php'; echo "</FORM></BODY></HTML>"; } // end list pipe screen --------------------------
/* ------------------------------------------------------ *\ ** pipe Detail screen \* ------------------------------------------------------ */ function pipe_detail() { global $debug, $err_num, $err_msg, $wrn_num, $wrn_msg, $spipe_id, $rqst, $fprog, $help, $site_num, $winery, $user_num, $link_id, $mt, $ih;
global $f_hub, $f_port, $t_hub, $t_port, $num_hoses, $clip;
if ($debug) echo "IN DT rqst: $rqst spipe_id# $spipe_id Site:$site_num<BR>";
// ----------- first time ------------- if ($fprog <> 'DT') { @list ($hub,$port) = explode("|",$spipe_id);
$sql = " SELECT * FROM pipe_hub WHERE pipe_hub.site_num = $site_num AND pipe_hub.f_hub = '$hub' AND pipe_hub.f_port = $port LIMIT 1"; $result = mysql_query($sql, $link_id); $query_data = @mysql_fetch_array($result); $f_hub = $query_data["f_hub"]; $f_port = $query_data["f_port"]; $t_hub = $query_data["t_hub"]; $t_port = $query_data["t_port"]; $num_hoses = $query_data["num_hoses"]; $clip = $query_data["clip"];
if ($debug) echo "$result|$sql<BR>"; }
$x = html_header();
echo "<TABLE BORDER='1' CELLPADDING='0' CELLSPACING='0' BGCOLOR='#EDEAE0'>"; echo "<TR><TD COLSPAN='4' BGCOLOR='#D0BFB3'><P ALIGN='CENTER'><B>Pipe Hub Exceptions</B></TD></TR>"; echo "$ih 'spipe_id' VALUE='$spipe_id'>"; if ($rqst == 'Add') { echo "<TR><TD><P ALIGN='RIGHT'><B>From Hub</B></TD>"; echo "<TD><INPUT TYPE='TEXT' NAME='f_hub' SIZE='3' MAXLENGTH='3' VALUE='$f_hub'></TD>"; echo "<TD><P ALIGN='RIGHT'><B>Port</B></TD>"; echo "<TD><INPUT TYPE='TEXT' NAME='f_port' SIZE='3' MAXLENGTH='3' VALUE='$f_port'></TD>"; } else {
echo "<TR><TD><P ALIGN='RIGHT'><B>From Hub</B></TD>"; echo "<TD><B>$f_hub</TD>"; echo "$ih 'f_hub' VALUE='$f_hub'>";
echo "<TD><P ALIGN='RIGHT'><B>Port</B></TD>"; echo "<TD><B>$f_port</TD></TR>"; echo "$ih 'f_port' VALUE=$f_port"; } echo "<TR><TD><P ALIGN='RIGHT'><B>To Hub</B></TD>"; echo "<TD><INPUT TYPE='TEXT' NAME='t_hub' SIZE='3' MAXLENGTH='3' VALUE='$t_hub'></TD>"; echo "<TD><P ALIGN='RIGHT'><B>Port</B></TD>"; echo "<TD><INPUT TYPE='TEXT' NAME='t_port' SIZE='3' MAXLENGTH='3' VALUE='$t_port'></TD></TR>"; echo "<TR><TD><P ALIGN='RIGHT'><B>Num Hoses</B></TD>"; echo "<TD COLSPAN=3><INPUT TYPE='TEXT' NAME='num_hoses' SIZE='5' MAXLENGTH='5' VALUE='$num_hoses'></TD>"; echo "<TR><TD><P ALIGN='RIGHT'><B>Clip</B></TD>"; echo "<TD colspan=3><INPUT TYPE='TEXT' NAME='clip' SIZE='3' MAXLENGTH='3' VALUE='$clip'></TD>"; echo "</TR>";
echo "</TABLE>"; include "in_buttons_dt.php"; // echo "</CENTER></FORM></BODY></HTML>"; } // ------- end detail screen -------------- ?>
|
|
|
Post by donnybowers on Dec 1, 2019 6:12:40 GMT -5
I've often thought about converting LB to PHP, but it seems like a huge undertaking for one person. I really like PHP for web development, but for me it would be so much easier to convert LB to PHP. I can do some simple PHP programming, but I'm constantly having to look up commands and syntax. Having an LB to PHP converter would make life easier.
There is a big difference between the kinds of programs developed for the web and the kinds developed for a PC desktop. But the nice thing about PHP is that you can use it on any computer that has an internet browser, a web server and PHP installed regardless of operating system.
|
|
|
Post by metro on Dec 1, 2019 9:09:08 GMT -5
I wonder how difficult it would be to merge Runbasic 2.0 with LB5? So you're only developing one codebase Just a thought
|
|
|
Post by Carl Gundel on Dec 1, 2019 14:14:01 GMT -5
I wonder how difficult it would be to merge Runbasic 2.0 with LB5? So you're only developing one codebase Just a thought LB5 is based on Run BASIC. You think they should be one product?
|
|
ntech
New Member
Posts: 49
|
Post by ntech on Dec 1, 2019 15:18:28 GMT -5
The integration of LB and Run BASIC would be really cool.
|
|
|
Post by Carl Gundel on Dec 1, 2019 17:41:22 GMT -5
The integration of LB and Run BASIC would be really cool. I guess it might be an exciting product that could do desktop and web programming. Maybe. I was working on a subscription service that for $5/month would let you write your own programs in BASIC and run them from anywhere you had a web browser.
|
|
|
Post by metro on Dec 1, 2019 18:19:41 GMT -5
I wonder how difficult it would be to merge Runbasic 2.0 with LB5? So you're only developing one codebase Just a thought LB5 is based on Run BASIC. You think they should be one product? I'm just a very average hobby programmer so my point of view maybe irrelevant, but I have seen more talented folk frustrated with some limitations with Runbasic
to the point that they have given up. I visit the RB forum four or five times a week, the lights are out and I only hear crickets. There have been some calls for LB5 to have HTML capabilities especially Dan's quest for a <table> format for displaying data.
Then of course as a LINUX user with a 64bit OS I can't use Runbasic, yes I could use my windows laptop but that's annoying.
From an income prospective it may make sense to have two different products but at this rate I think a cashflow from RB2.0 could be a way off.
I just thought it maybe easier to have LB5 ...LB5Pro....LB5Pro(Plus)+ which includes RB2.0 Anyway.... as I stated Just a thought.
|
|
|
Post by sarossell on Dec 1, 2019 21:25:33 GMT -5
If I may put my two cents in... Carl, whatever you decide to do, I'm just thrilled to see development on Liberty Basic 5 for the Mac. I was languishing with Xojo and it was just soul-crushing to not be able to grasp that language as easily as I have with LB. That being said, I must admit I enjoyed the ability to compile Xojo code for Mac, Linux, PC, Web and even the Raspberry Pi by merely checking a box. Granted, if LB 5 had similar functionality, that would be amazing, but honestly just being able to run and compile native LB code on the Mac (and Raspberry Pi) sounds like a dream come true for me. If it could also compile for the web using Run Basic, that would just be well-appreciated icing on an already amazing cake. Bottom line, I simply *LOVE* being able to pull up LB and write code almost exactly as I did when I first learned how to program nearly 40 years ago. Thank you!
|
|
|
Post by donnybowers on Dec 2, 2019 9:44:03 GMT -5
Then of course as a LINUX user with a 64bit OS I can't use Runbasic, yes I could use my windows laptop but that's annoying. Most Linux distros I'm familiar with have 32 bit compatibility files that you can install. Ubuntu and most Ubuntu derivatives have it and you can run RB on them. I would think most major distros would have it available in their software installers .
|
|
|
Post by metro on Dec 2, 2019 18:40:31 GMT -5
Then of course as a LINUX user with a 64bit OS I can't use Runbasic, yes I could use my windows laptop but that's annoying. Most Linux distros I'm familiar with have 32 bit compatibility files that you can install. Ubuntu and most Ubuntu derivatives have it and you can run RB on them. I would think most major distros would have it available in their software installers .
Thanks donnybowers, I have exhausted that avenue, and from time to time I research again to find a solution but...no luck it all started just over 7 years ago if the link doesn't work search for Runbasic
|
|
|
Post by meerkat on Dec 3, 2019 5:55:58 GMT -5
I guess since I started this post, I'll chime in. Like others I tried to get CGI (Common Gateway Interface) to work, but failed. Because HTML makes it so easy to do user interfaces I use RB over LB. I tried LB5 but always end up using RB. If RB fixed a couple bugs, I'd do everything in RB. Most of the stuff I do has more than one user. So a web interface like RB lets all users run the same code. And today almost everyone has a static IP that lets them run as a server. Basically I can't use LB, and can't use RB. I love the basic language code. And when writing complex stuff, you can pick up the code a year later and understand what it does. Real time stuff in RB such as scales, gauges are a problem, but once solved with JS or other means it's not a problem. So my vote, for what it's worth, is to somehow combine LB and RB or add CGI. It that worked, I'd move everything back from REBOL.
|
|
|
Post by Chris Iverson on Dec 3, 2019 14:21:40 GMT -5
CGI can't currently be done because there's no direct way to read from and write to standard input/output, and no direct way to read environment variables.
These can be done in LB4 via API calls, but I don't know if it can let you do so early enough to capture the input from CGI.
If a way to do such things was added to LB(which would improve interactivity with other batch and command line programs, as well, not just CGI), then it would be possible.
|
|