55session_start ();
66$ bg =2 ;
77$ step =20 ;
8- $ version ="3.22 " ;
8+ $ version ="3.23 " ;
99$ bbs =['False ' ,'True ' ];
1010$ deny =['mysql ' ,'information_schema ' ,'performance_schema ' ,'sys ' ];
1111class DBT {
@@ -25,12 +25,13 @@ public function __construct($host,$user,$pwd,$db) {
2525 $ ty =self ::$ sqltype ;
2626 if (extension_loaded ($ ty [0 ])) $ this ->dbty =$ ty [0 ];
2727 else $ this ->dbty =$ ty [1 ];
28+ $ host =explode (": " ,$ host );
2829 if ($ this ->dbty ==self ::$ sqltype [0 ]) {
2930 mysqli_report (MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT );
30- $ this ->_cnx =new mysqli ($ host ,$ user ,$ pwd ,$ db );
31+ $ this ->_cnx =new mysqli ($ host[ 0 ] ,$ user ,$ pwd ,$ db, empty ( $ host [ 1 ])? 3306 : $ host [ 1 ] );
3132 mysqli_report (MYSQLI_REPORT_OFF );
3233 } else {
33- $ this ->_cnx =new PDO ("mysql:host= " .$ host .";dbname= " .$ db ,$ user ,$ pwd );
34+ $ this ->_cnx =new PDO ("mysql:host= " .$ host[ 0 ]. " ;port= " .( empty ( $ host [ 1 ])? 3306 : $ host [ 1 ]) .";dbname= " .$ db ,$ user ,$ pwd );
3435 $ this ->_cnx ->setAttribute (PDO ::ATTR_ERRMODE ,PDO ::ERRMODE_EXCEPTION );
3536 }
3637 }
@@ -1385,14 +1386,12 @@ public function create_ro($db,$pn) {
13851386 $ colu []=$ r_brw ['Null ' ];
13861387 }
13871388 if ($ ed ->post ('save ' ,'i ' ) || $ ed ->post ('save2 ' ,'i ' )) {
1388- $ q_res =$ ed ->con ->query ("SELECT * FROM ` $ tb` " );
1389- $ nrcol =$ q_res ->num_col ();
13901389 $ qr1 ="INSERT INTO ` $ tb` ( " ;
13911390 $ qr2 ="" ;
13921391 $ qr3 ="VALUES( " ;
13931392 $ qr4 ="" ;
13941393 $ n =0 ;
1395- while ($ n <$ nrcol ) {
1394+ while ($ n <count ( $ coln ) ) {
13961395 if ($ ed ->post ('r ' .$ n ,'!e ' ) || !empty ($ _FILES ["r " .$ n ]['tmp_name ' ])) {
13971396 $ qr2 .=$ coln [$ n ].", " ;
13981397 if (stristr ($ colt [$ n ],"blob " )==true ) {
@@ -1424,10 +1423,8 @@ public function create_ro($db,$pn) {
14241423 else $ ed ->redir ("$ rr/ $ db/ $ tb " ,['err ' =>"Insert failed " ]);
14251424 } else {
14261425 echo $ head .$ ed ->menu ($ db ,$ tb ,1 ).$ ed ->form ("21/ $ db/ $ tb " ,1 )."<table><caption>Insert Row</caption> " ;
1427- $ q_res =$ ed ->con ->query ("SELECT * FROM ` $ tb` " );
1428- $ r_col =$ q_res ->num_col ();
14291426 $ j =0 ;
1430- while ($ j <$ r_col ) {
1427+ while ($ j <count ( $ coln ) ) {
14311428 echo "<tr><td> " .$ coln [$ j ]."</td><td> " ;
14321429 if (stristr ($ colt [$ j ],"enum " )==true OR stristr ($ colt [$ j ],"set " )==true ) {//enum
14331430 $ enums =explode ("',' " ,preg_replace ("/(enum|set)\('(.+?)'\)/ " ,"\\2 " ,$ colt [$ j ]));
@@ -1479,12 +1476,10 @@ public function create_ro($db,$pn) {
14791476 }
14801477 $ nul =("( " .$ nu ." IS NULL OR " .$ nu ."='') " );
14811478 if ($ ed ->post ('edit ' ,'i ' )) {//update
1482- $ q_re2 =$ ed ->con ->query ("SELECT * FROM ` $ tb` " );
1483- $ r_co =$ q_re2 ->num_col ();
14841479 $ qr1 ="UPDATE ` $ tb` SET " ;
14851480 $ qr2 ="" ;
14861481 $ p =0 ;
1487- while ($ p <$ r_co ) {
1482+ while ($ p <count ( $ coln ) ) {
14881483 if (stristr ($ colt [$ p ],"blob " )==true ) {
14891484 if (!empty ($ _FILES ["te " .$ p ]['tmp_name ' ])) {
14901485 $ blb =addslashes (file_get_contents ($ _FILES ["te " .$ p ]['tmp_name ' ]));
@@ -1504,14 +1499,12 @@ public function create_ro($db,$pn) {
15041499 if ($ q_upd ) $ ed ->redir ("20/ $ db/ $ tb " ,['ok ' =>"Successfully updated " ]);
15051500 else $ ed ->redir ("20/ $ db/ $ tb " ,['err ' =>"Update failed " ]);
15061501 } else {//edit form
1507- $ q_flds =$ ed ->con ->query ("SHOW COLUMNS FROM ` $ tb` " );
1508- $ r_fnr =$ q_flds ->num_row ();
15091502 $ q_rst =$ ed ->con ->query ("SELECT " .implode (", " ,$ cols )." FROM ` $ tb` WHERE " .($ id =="" ?$ nul :$ nu ."=' " .addslashes ($ id )."' " ).(!empty ($ colt [1 ]) && stristr ($ colt [1 ],"blob " )==false && !empty ($ nu1 ) && !empty ($ id1 )?" AND $ nu1=' " .addslashes ($ id1 )."' " :"" ));
15101503 if ($ q_rst ->num_row () < 1 ) $ ed ->redir ("20/ $ db/ $ tb " ,['err ' =>"Edit failed " ]);
15111504 $ r_rx =$ q_rst ->fetch ();
15121505 echo $ head .$ ed ->menu ($ db ,$ tb ,1 ).$ ed ->form ("22/ $ db/ $ tb/ $ nu/ " .($ id =="" ?"isnull " :base64_encode ($ id )).(!empty ($ colt [1 ]) && stristr ($ colt [1 ],"blob " )==false && !empty ($ nu1 ) && !empty ($ id1 )?"/ $ nu1/ " .base64_encode ($ r_rx ['1 ' ]):"" ),1 )."<table><caption>Edit Row</caption> " ;
15131506 $ k =0 ;
1514- while ($ k <$ r_fnr ) {
1507+ while ($ k <count ( $ coln ) ) {
15151508 echo "<tr><td> " .$ coln [$ k ]."</td><td> " ;
15161509 if (stristr ($ colt [$ k ],"enum " )==true OR stristr ($ colt [$ k ],"set " )==true ) {//enum
15171510 $ enums =explode ("',' " ,preg_replace ("/(enum|set)\('(.+?)'\)/ " ,"\\2 " ,$ colt [$ k ]));
@@ -1654,10 +1647,10 @@ public function create_ro($db,$pn) {
16541647 $ q_op =$ ed ->con ->query ($ op ." TABLE " .$ tb );
16551648 if ($ op =='check ' || $ op =='repair ' ) {
16561649 $ r_op =$ q_op ->fetch ();
1657- if ($ r_op [3 ]=='OK ' ) $ ed ->redir ("10/ $ db/ $ tb " ,['ok ' =>"Successfully { $ op } ed " ]);
1650+ if ($ r_op [3 ]=='OK ' ) $ ed ->redir ("10/ $ db/ $ tb " ,['ok ' =>"Successfully executed " ]);
16581651 else $ ed ->redir ("10/ $ db/ $ tb " ,['err ' =>$ r_op [3 ]]);
16591652 }
1660- $ ed ->redir ("10/ $ db/ $ tb " ,['ok ' =>"Successfully { $ op } d " ]);
1653+ $ ed ->redir ("10/ $ db/ $ tb " ,['ok ' =>"Successfully executed " ]);
16611654 } else $ ed ->redir ("10/ $ db/ $ tb " ,['err ' =>"Action {$ op } failed " ]);
16621655break ;
16631656
0 commit comments