[Firebug-cvs] firebug/web/postgres config.php,1.1,1.2 connect.php,1.4,1.5 db_list.php,1.1,1.2 db_lis
Brought to you by:
doolin
From: Karthik D. <da...@us...> - 2005-06-06 19:23:37
|
Update of /cvsroot/firebug/firebug/web/postgres In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24575 Modified Files: config.php connect.php db_list.php db_list_databases.php db_select.php db_table_buttons.php Log Message: Updated postgres access to php code Index: db_list.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_list.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_list.php 19 Aug 2004 16:27:38 -0000 1.1 --- db_list.php 6 Jun 2005 19:23:19 -0000 1.2 *************** *** 15,24 **** <center> ! <form action="db_select.php" method="post"> ! ! <?php ! include("db_list_databases.php"); ! ?> ! <input type="submit" value="Show tables"> </form> --- 15,22 ---- <center> ! <form action="db_select.php" method="post"> ! <!-- Make sure you include this inside the form action !> ! <!-- the variable scoping will get messed up otherwise; !> ! <?php include("db_list_databases.php"); ?> <input type="submit" value="Show tables"> </form> Index: config.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/config.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** config.php 4 Jun 2005 08:35:57 -0000 1.1 --- config.php 6 Jun 2005 19:23:19 -0000 1.2 *************** *** 1,4 **** ! $webroot=192.168.1.131 ! $defaultdb='task' ! $port=5432 ! $user='postgres' --- 1,6 ---- ! <?php ! $webroot='192.168.1.131'; ! $defaultdb='task'; ! $port=5432; ! $user='postgres'; ! ?> \ No newline at end of file Index: db_table_buttons.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_table_buttons.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** db_table_buttons.php 19 Aug 2004 21:59:57 -0000 1.2 --- db_table_buttons.php 6 Jun 2005 19:23:19 -0000 1.3 *************** *** 9,13 **** print("<table class='db_schema'>"); ! $dbh = connect_postgres($dbname); $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; --- 9,13 ---- print("<table class='db_schema'>"); ! $dbh = connect_postgres($dbname) or die("Unable to connect to database"); $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; Index: db_list_databases.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_list_databases.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** db_list_databases.php 4 Jun 2005 08:35:57 -0000 1.3 --- db_list_databases.php 6 Jun 2005 19:23:19 -0000 1.4 *************** *** 7,12 **** <?php include("connect.php"); ! $dbh = connect_postgres($defaultdb) or die("Unable to connect to database"); ! $statement = "SELECT DATNAME FROM pg_database where not datname=$defaultdb and not datname='template0'"; $stat = @pg_exec($dbh,$statement) or die("Unable to select database name"); if (!stat) { --- 7,12 ---- <?php include("connect.php"); ! $dbh = connect_postgres("task") or die("Unable to connect to database"); ! $statement = "SELECT DATNAME FROM pg_database where not datname='template1' and not datname='template0'"; $stat = @pg_exec($dbh,$statement) or die("Unable to select database name"); if (!stat) { *************** *** 16,20 **** for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i) or die("Could not fetch data"); print ("<tr><td>"); print $data[0]; --- 16,20 ---- for ($i = 0; $i < $rows; $i++) { ! $data = pg_fetch_row($stat, $i) or perr("db_list_databases", "Could not fetch data"); print ("<tr><td>"); print $data[0]; *************** *** 28,32 **** } } ! pg_close($dbh) or die("Could not close database"); ?> --- 28,32 ---- } } ! pg_close($dbh) or perr("db_list_databases", "Could not close database"); ?> Index: connect.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/connect.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** connect.php 4 Jun 2005 08:35:57 -0000 1.4 --- connect.php 6 Jun 2005 19:23:19 -0000 1.5 *************** *** 6,16 **** include("config.php"); function connect_postgres($db) { ! $connstr = "dbname=$db user=$user host=$webroot port=$port"; if(!($dbh = @pg_connect($connstr))) { ! die("<strong>ERROR</strong>: Could not connect"); } return $dbh; } - ?> \ No newline at end of file --- 6,20 ---- include("config.php"); + function perr($fname, $err) { + $pstring = "<strong>ERROR</strong>: ".$err. " in ".$fname; + die($pstring); + } + function connect_postgres($db) { ! $connstr = "dbname=$db user=postgres host=192.168.1.131 port=5432"; if(!($dbh = @pg_connect($connstr))) { ! print("connect". "Could not connect to database\n"); } return $dbh; } ?> \ No newline at end of file Index: db_select.php =================================================================== RCS file: /cvsroot/firebug/firebug/web/postgres/db_select.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** db_select.php 19 Aug 2004 21:59:57 -0000 1.2 --- db_select.php 6 Jun 2005 19:23:19 -0000 1.3 *************** *** 13,21 **** <?php include("connect.php"); ! $dbname = $HTTP_POST_VARS["db1"]; ! $dbh = connect_postgres($dbname); ! print("<h1>Database $dbname tables</h1>"); print("<center>\n"); --- 13,21 ---- <?php include("connect.php"); ! $db = $HTTP_POST_VARS["db1"]; ! $dbh = connect_postgres($db) or perr("db_select", "Unable to connect"); ! print("<h1>Database $db tables</h1>"); print("<center>\n"); *************** *** 23,29 **** $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; $stat = @pg_exec($dbh,$statement); if (!$stat) { ! print "<strong>ERROR</strong>: Could not access list of tables for database <strong>".strtoupper($dbname)."</strong>."; } else { $rows = pg_numrows($stat); --- 23,30 ---- $statement = "SELECT TABLENAME FROM pg_tables WHERE NOT TABLENAME~'pg_.*' and not tablename~'sql_.*'"; + //$statement = "SELECT TABLENAME FROM pg_tables"; $stat = @pg_exec($dbh,$statement); if (!$stat) { ! perr("db_select", "Could not access list of tables for database ".strtoupper($d). "."); } else { $rows = pg_numrows($stat); *************** *** 45,49 **** print ("</table>"); ! print ("<input type=hidden name=db1 value=\"$dbname\">"); print ("<input type=submit value=SUBMIT>"); } --- 46,50 ---- print ("</table>"); ! print ("<input type=hidden name=db1 value=\"$db\">"); print ("<input type=submit value=SUBMIT>"); } |