[Firebug-cvs] firebug/web/gmaps config.php,NONE,1.1 connect.php,NONE,1.1 db_admin.php,NONE,1.1 db_cr
Brought to you by:
doolin
Update of /cvsroot/firebug/firebug/web/gmaps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26384 Added Files: config.php connect.php db_admin.php db_create.php db_drop.php db_dropdb.php db_gmap.php db_list.php db_list_databases.php db_render_xml.php db_select.php db_table_buttons.php db_table_select.php db_xml_create.php firebug.css geocodeinfo_rfs.xsl gmaps.html gmaps.xml gmaps_update.php hello.php main.css nav_footer.php Log Message: Added new dir for google maps. KAR. --- NEW FILE: db_dropdb.php --- <html> <head> <title>FireBug database utility script</title> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <h1>FireBug database dropped</h1> <?php $dbname = $HTTP_POST_VARS["db1"]; ?> <hr /> <?php include("connect.php"); $dbh= connect_postgres("task"); $statement = "DROP DATABASE $dbname"; $stat = @pg_exec($dbh,$statement); if (!$stat) { print "<strong>ERROR</strong>: Could not drop database <strong>".strtoupper($dbname)."</strong>."; } else { print "Database <strong>$dbname</strong> dropped."; } pg_close($dbh); ?> <br /> <hr /> <?php include("nav_footer.php"); ?> <hr /> </body> </html> --- NEW FILE: db_create.php --- <html> <head> <title>FireBug database utility script</title> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <h1>FireBug database created</h1> <?php include("connect.php"); /* Note: All database names are lower-case in postgresql.*/ $dbname = strtolower($HTTP_POST_VARS["dbname"]); $nummotes = $HTTP_POST_VARS["nummotes"]; /** Need php v4.2 for this to work. */ /* Check to make sure we have numbers intead of garbage.*/ /* if (!ctype_digit($nummotes)) { print "Must be digits.<br />"; } */ /* Check to see if database exists already. */ $dbh = connect_postgres("task"); $statement = "SELECT DATNAME FROM pg_database where not datname=$defaultdb"; $conn_stat = @pg_exec($dbh,$statement); if (!$conn_stat) { print "<strong>ERROR</strong>: Could not check to see if database <strong>".strtoupper($dbname)."</strong> exists."; pg_close($dbh); } else { $rows = pg_numrows($conn_stat); $flag=0; for ($i = 0; $i < $rows; $i++) { $data = pg_fetch_row($conn_stat, $i); if (strcmp(rtrim($data[0]),$dbname)==0) { $flag=1; } } pg_close($dbh); /* Creates the database if it does not exist yet.*/ if (!$flag) { $dbh = connect_postgres($defaultdb); $statement = "CREATE DATABASE $dbname"; $create_stat = @pg_exec($dbh,$statement); if (!$create_stat) { print "<strong>ERROR</strong>: Could not create database <strong>".strtoupper($dbname)."</strong>."; pg_close($dbh); } else { print "Database <strong>$dbname</strong> created."; print "<br />"; pg_close($dbh); $dbh = connect_postgres($dbname); /* 3 create table statements for firebug sensors. */ /* typedef struct GGAMsg { uint16_t mote_id uint8_t hours; uint8_t minutes; float dec_sec; uint8_t Lat_deg; float Lat_dec_min; uint8_t Long_deg; float Long_dec_min; uint8_t NSEWind; uint8_t num_sats; } GGAMsg; */ $sql = "CREATE TABLE location (mote_id SMALLINT, gps_hours SMALLINT, gps_minutes SMALLINT, gps_seconds REAL, lat_deg SMALLINT,"; $sql .= "lat_dec_min REAL, long_deg SMALLINT, long_dec_min REAL, nsew SMALLINT, numsats SMALLINT)"; $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { print "<strong>ERROR</strong>: Could not create table </strong>LOCATION</strong>."; } //$statement = "CREATE TABLE location (mote_id SMALLINT, gps_hours SMALLINT, gps_minutes SMALLINT, gps_seconds FLOAT, lat_deg SMALLINT,"; //$statement .= "lat_dec_min FLOAT, long_deg SMALLINT, long_dec_min FLOAT, nsew SMALLINT, numsats SMALLINT)"; /* typedef struct Firedata_msg { uint16_t mote_id; uint16_t cnt; float temp; float rel_hum; float baro_pres; float lux; } Firedata_msg; */ $sql = "CREATE TABLE current (mote_id SMALLINT, time TIMESTAMP, cnt SMALLINT, temp REAL, rel_hum REAL, baro_pres REAL, lux REAL)"; $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { print "<strong>ERROR</strong>: Could not create table <strong>CURRENT</strong>."; $current_flag=1; } //$statement = "CREATE TABLE current (mote_id SMALLINT, time TIMESTAMP, cnt SMALLINT, temp FLOAT, rel_hum FLOAT, baro_pres FLOAT, lux FLOAT)"; //mysql_query($statement) or die("Error: ".mysql_error()." in creating current atable"); $sql = "CREATE TABLE cumulative (mote_id SMALLINT, time TIMESTAMP, cnt SMALLINT, temp REAL, rel_hum REAL, baro_pres REAL, lux REAL)"; $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { print "<strong>ERROR</strong>: Could not create table <strong>CUMULATIVE</strong>."; } //$statement = "CREATE TABLE cumulative (mote_id SMALLINT, time TIMESTAMP, cnt SMALLINT, temp FLOAT, rel_hum FLOAT, baro_pres FLOAT, lux FLOAT)"; //mysql_query($statement) or die("Error: ".mysql_error()." in creating cumulative atable"); $sql = "CREATE TABLE range (mote_id SMALLINT, time TIMESTAMP, count INTEGER, rssi INTEGER, voltage REAL)"; $create_stat = @pg_exec($dbh, $sql); if (!$create_stat) { print "<strong>ERROR</strong>: Could not create table <strong>RANGE</strong>."; } //$statement = "CREATE TABLE range (mote_id SMALLINT, time TIMESTAMP, count INTEGER, rssi INTEGER, voltage FLOAT)"; //mysql_query($statement) or die("Error: ".mysql_error()." in creating range table"); } ?> <?php if (!$current_flag) { for ($i = 1; $i <= $nummotes; $i++) { $statement = "INSERT INTO current (mote_id) VALUES ($i)"; print "<br />"; $create_stat = @pg_exec($dbh, $statement); if (!$create_stat) { print "<strong>ERROR</strong>: Could not INSERT INTO <strong>CURRENT</strong> (mote_id) VALUES ($i)"; } else { print $statement; } } } pg_close($dbh); } else { echo("Database $dbname already created."); print "<br />"; echo("Please create another database."); print "<br />"; print("<a href=\"db_admin.php\">Create Another Database</a>"); } } ?> <br /> <hr /> <?php include("nav_footer.php"); ?> <hr /> </body> </html> --- NEW FILE: main.css --- BODY, TD, P { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;} .black { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000;} .grey { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #676767;} .white { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #FFFFFF;} a.white { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight:bold; color: #FFFFFF;} .orange {color: #FF6600;} .titlered {color: #960707; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 18px; font-weight:bold;} .titleorange {color: #CC6633; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 18px; font-weight:bold;} .red { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #990000;} .small {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; font-weight:normal;} a.nav-main { font-size: 10px; color: #FFFFFF; font-weight:bold; text-decoration:none; } a.nav-main:hover { font-size: 10px; color: #FFF; font-weight:bold; text-decoration:none; } a.nav-sub { font-size: 10px; color: #FFFFFF; text-decoration:none; } a.nav-sub:hover { font-size: 10px; color: #CCCCCC; text-decoration:none; } A { font-family: Verdana, Arial, Helvetica, sans-serif; color: #0066CC;} A:HOVER { color: #FF9900; text-decoration: underline;} A:HOVER.white { color: #FFFFDD; text-decoration: underline;} A:HOVER.black { color: #FF9900; text-decoration: underline;} A:HOVER.orange { color: #993300; text-decoration: underline;} A.small { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #0066CC;} .topnav { font-size: 10px;} .topnav_active {background-color:#FDCD85; color:#394D73; font-weight: bold; font-size: 10px;} a.topnav{font-weight: bold; text-decoration:none; color:#394D73;} a.topnav:hover{background-color:#FDCD85; color:#394D73; text-decoration:none;} .header { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; color: #000000; font-weight: bold;} .headerwhite { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; color: #FFFFFF; font-weight: bold;} .wl {font-family:verdana, Helvetica, Sans-Serif; font-size: 12px; font-weight:bold; color:#666633;} .wlt {font-family:verdana, Helvetica, Sans-Serif; font-size: 11px; color:#666633;} .blueh {font-family:verdana, Helvetica, Sans-Serif; font-size: 13px;font-weight:bold;color:#336699;} .bluet {font-family:verdana, Helvetica, Sans-Serif; font-size: 12px;color:#336699;} .bluetsml {font-family:verdana, Helvetica, Sans-Serif; font-size: 10px; color:#336699;} .bluetout {font-family:verdana, Helvetica, Sans-Serif; font-size: 10px;color:#336699;} .boldsmall {font-family:verdana, Helvetica, Sans-Serif; font-size: 10px;color:#000000; font-weight:bold} .spacer1p {margin-top:1px;} .spacer2p {margin-top:2px;} .spacer4p {margin-top:4px;} .spacer5p {margin-top:5px;} .spacer7p {margin-top:7px;} .spacer10p {margin-top:10px;} .spacer12p {margin-top:12px;} .spacer15p {margin-top:15px;} .spacer20p {margin-top:20px;} .spacer25p {margin-top:25px;} .navbox {margin-top:2px;} TR.NavRow TD { vertical-align: middle; border: 1px solid; border-color: #369 #003 #003; border-left: none; cursor: pointer; } .Nav { background-color: #384ccc; color: #fff; cursor: pointer; } .NavText, .NavHighlightText, .NavGroupText { font-family: verdana, arial, sans-serif; font-size: 10px; font-weight: bold; line-height: 14px; padding-left: 6px; text-decoration: none; } .Nav A:link, .Nav A:visited { color: #fff; Text-decoration: none;} .NavHilite { background-color: #5A6B94; color: #fff; } .NavHilite A:link, .NavHilite A:visited { color: #fff; } TR TD.NavHilite A:link, TR TD.NavHilite A:visited { text-decoration: none; } TR.NavHiliteRow TD { vertical-align: middle; border: 1px solid; border-color: #000 #5A6B94 #000; border-left: none; } --- NEW FILE: db_select.php --- <html> <head> <title>FireBug database utility script</title> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <form action="db_gmap.php" method="post"> <?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"); print("<table class='db_schema'><tr><td>Table Name</td><td>Selected</td></tr>"); $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); for ($i = 0; $i < $rows; $i++) { $data = pg_fetch_row($stat, $i); print ("<tr>"); print ("<td>"); print $data[0]; print ("</td>"); print ("<td>"); print ("<input type=radio name=tbl1 value=\"" . htmlspecialchars($data[0]) . "\">"); print ("</td>"); print ("</tr>"); } print ("</table>"); print ("<input type=hidden name=db1 value=\"$db\">"); print ("<input type=submit value=SUBMIT>"); } pg_close($dbh); ?> </form> </center> <br /> <hr /> <?php include("nav_footer.php"); ?> <hr /> </body> </html> --- NEW FILE: db_table_select.php --- <?php //session_start(); //session_register("dbname"); //session_register("tblname"); ?> <html> <head> <title>FireBug Client</title> <!-- <META HTTP-EQUIV="Refresh" CONTENT="30;URL=http://localhost/firebug/db_table_select.php"> --> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <hr /> <p> Sensor data last updated: <?php echo date ("l dS F Y h:i:s A"); ?> </p> <?php if ($HTTP_POST_VARS["tbl1"]!=Null){ $HTTP_SESSION_VARS["tblname"] = $HTTP_POST_VARS["tbl1"]; $HTTP_SESSION_VARS["dbname"] = $HTTP_POST_VARS["db1"]; } $dbname = $HTTP_SESSION_VARS["dbname"]; $tblname = $HTTP_SESSION_VARS["tblname"]; print("<h1>Mote activity: Database $dbname, table $tblname</h1>"); ?> <?php include("db_table_buttons.php"); ?> <center> <table class="db_schema"> <?php $dbh = connect_postgres($dbname); $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname ='$tblname' and a.attrelid = c.oid and a.attnum > 0"; $stat = @pg_exec($dbh,$statement); if (!$stat) { print "<strong>ERROR</strong>: Could not retrieve table header column names for<strong>".strtoupper($tblname)."</strong>."; } else { // Build the table header column names. Make this into a function. print("<tr>\n"); $cols = pg_numrows($stat); for ($i=0 ; $i < $cols; $i++) { print ("<td style=\"border: solid\"><b><align=center><h2>"); $header = pg_fetch_row($stat,$i); print $header[0]; print ("<//h2></b></td>"); } print("</tr>\n"); $statement = "SELECT * FROM $tblname"; $stat = @pg_exec($dbh,$statement); if (!$stat) { print "<strong>ERROR</strong>: Could not access table <strong>".strtoupper($tblname)."</strong>."; } else { //Print the value for a row. function print_row($item2,$key) { print ("<td style=\"border-right: solid\" align=\"center\">\n"); echo "$item2\n"; print ("</td>\n"); } //Print every row. $rows = pg_numrows($stat); // for each row for ($i=0;$i<$rows;$i++) { print ("<tr>"); // For each column... $row = array_values(pg_fetch_row($stat,$i)); array_walk($row,'print_row'); print("</tr>"); } } pg_close($dbh); } ?> </table> </center> <hr /> <hr /> <?php include("nav_footer.php"); ?> <hr /> <p> Sensor data last updated: <?php echo date ("l dS F Y h:i:s A"); ?> </p> </body> </html> --- NEW FILE: db_render_xml.php --- <p> <?php include("connect.php"); /* if ($HTTP_POST_VARS["tbl1"]!=Null){ $HTTP_SESSION_VARS["tblname"] = $HTTP_POST_VARS["tbl1"]; $HTTP_SESSION_VARS["dbname"] = $HTTP_POST_VARS["db1"]; } $dbname = $HTTP_SESSION_VARS["dbname"]; $tblname = $HTTP_SESSION_VARS["tblname"]; */ print("<?xml version=\"1.0\"?>\n"); print("<page>\n"); print("<title>Richmond Field Station Demo</title>\n"); print("<query>Demo?</query>\n"); print("<request/>\n"); print("<center lat=\"37.9177\" lng=\"-122.332\"/>\n"); print("<!-- Original -->\n"); print("<!--\n"); print("<span lat=\"0.0179\" lng=\"0.027586\"/>\n"); print("-->\n"); print("<span lat=\"0.002\" lng=\"0.003\"/>\n"); print("<overlay panelStyle=\"sidepanel.xsl\">\n"); $dbname = "task"; $tblname = "gga_l"; $dbh = connect_postgres($dbname); $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname ='$tblname' and a.attrelid = c.oid and a.attnum > 0"; $stat = @pg_exec($dbh,$statement); if(!stat) { die("Cannot select from database\n"); } $statement = "SELECT * FROM $tblname"; $stat = @pg_exec($dbh,$statement); if(!stat) { die("Cannot select from table\n"); } /*** * * ***** FIXME ********* * The field labels are hardcoded in here. * You have to change the labels for this to work. * ***/ $rows = pg_numrows($stat); /*** * * Setting up google maps specific stuff * * $ids contains the ten ids that you can associate * with locations * * $ imgs lists the image icons that you can have * ***/ $ids=array('A','B','C','D','E','F','G','H','I','J'); $imgs=array('http://libgmail.sourceforge.net/man.png', 'http://libgmail.sourceforge.net/spider.png'); for ($i=0;$i<$rows;$i++) { printf("<location infoStyle=\"geocodeinfo_rfs.xsl\" id=\"%s\">\n", $ids[$i]) or perr("db_xml_create", "Cant fprintf"); $row = array_values(pg_fetch_row($stat,$i)) or perr("db_xml_create", "Cannot retrieve data"); foreach ($rows as $key => $value) { switch($key) { case "latitudedegree": $latdeg=$value; break; case "latitudeminutes": $latmin=$value; break; case "longitudedegree": $longdeg=$value; break; case "longtudeminute": $longmin=$value; break; default: $disp[$key]=$value; } } $lat = $latdeg + ($latmin/60.0); $long = $longdeg + ($longmin/60.0); printf("<point lat=\"%f\" lng=\"%f\"/>\n", $lat, $long) or perr("db_xml_create", "1"); printf("<icon image=\"%s\" class=\"local\"/>\n", $imgs[0]); print("<info>") or perr("db_xml_create","4"); print("<title xml:space=\"preserve\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\">\n") or perr("db_xml_create","5"); print("</title>\n") or perr("db_xml_create","6"); print("<address>\n") or perr("db_xml_create","8"); print("<line>Ms. Eva Green</line>\n") or perr("db_xml_create","9"); print("</address>\n") or perr("db_xml_create","10"); print("<image>\n") or perr("db_xml_create","11"); print("http://www.google.co.nz/images/logo_sm.gif\n") or perr("db_xml_create","12"); print("</image>\n") or perr("db_xml_create","13"); print("</info>\n") or perr("db_xml_create","14"); } pg_close($dbh); ?> </p> --- NEW FILE: config.php --- <?php $webroot='192.168.1.131'; $defaultdb='task'; $port=5432; $user='postgres'; ?> --- NEW FILE: db_gmap.php --- <html> <head> <title>Richmond Field Station Experiment</title> <script src="http://google.com/maps?file=js&hl=en" type="text/javascript"> </script> <script type="text/javascript"> _mSiteName = 'Richmond Field Station'; _mUsePrintLink=""; function initMap() { // // frb // myMapApp = new _MapsApplication(document.getElementById("container_frb"), document.getElementById("panel"), document.getElementById("metapanel"), document.getElementById("permalink"), document.getElementById("toggle"), document.getElementById("printheader")); myMapApp.loadMap(); /* Note: All XML & XSL files must be on same domain. */ _loadXmlFileFromURL("/firebug/web/gmaps/db_render_xml.php", myMapApp); } t.dump = function(a) {alert(a);} //debugging function _loadXmlFileFromURL(url, mapApp) { // // Loads the specified external XML file into the map view. // // frb // // NOTE: URL must be on same domain as page. var _getter = _XMLHttp.create(); _getter.open("GET", url); _getter.onreadystatechange=function() { if (_getter.readyState==4) { mapApp.loadXML(_getter.responseText); } } _getter.send(null); // Whoops, IE *needs* this to be last, Moz is lenient. } </script> <style type="text/css"> #panel table { border:solid 1px grey; width:50%; margin-bottom: 5px; } #panel table td:first-child { width: 24px; } .label { font-size:smaller; font-family:sans-serif; }; </style> </head> <body onload="initMap()"> <!----> <?php include("db_xml_create.php"); ?> <!-- Note: Map height always maximum? --> <div style="position:absolute;left:5px;top:10px;right:5px;border:solid thin grey;"> <div id="container_frb" style="float:right;width:35%;" > </div> <div style="float:left;position:relative;left:10px;width:60%"> <div style="position:absolute;left:0px;top:0px;width:50%;overflow:auto;"> <h1 style="font-family:sans-serif;font-size:medium;">Richmond Field Station Demo</h1> <p><dl> Sensor data last updated: </dl> </p> </div> <div style="position:absolute;left:50%;top:5px;width:50%;"> <div id="toggle" style="position:absolute;top:0px:left:10px;font-family:sans-serif;font-size:smaller;"> </div> <div style="position:absolute;top:30px;left:5px;"> <div id="panel" style="height:90%;width:100%;"> </div> <div id="metapanel">metapanel</div> <div id="permalink">permalink</div> <div id="printheader">header</div> </div> </div> </div> </div> <!-- </body> </html> --- NEW FILE: db_xml_create.php --- <?php if ($HTTP_POST_VARS["tbl1"]!=Null){ $HTTP_SESSION_VARS["tblname"] = $HTTP_POST_VARS["tbl1"]; $HTTP_SESSION_VARS["dbname"] = $HTTP_POST_VARS["db1"]; } $dbname = $HTTP_SESSION_VARS["dbname"]; $tblname = $HTTP_SESSION_VARS["tblname"]; // print("<h1>Mote activity: Database $dbname, table $tblname</h1>"); // include("db_table_buttons.php"); $dbh = connect_postgres($dbname); $statement = "SELECT a.attname FROM pg_attribute a,pg_class c where c.relname ='$tblname' and a.attrelid = c.oid and a.attnum > 0"; $stat = @pg_exec($dbh,$statement); if (!$stat) { print "<strong>ERROR</strong>: Could not retrieve table header column names for<strong>".strtoupper($tblname)."</strong>."; } else { $statement = "SELECT * FROM $tblname"; $stat = @pg_exec($dbh,$statement); if (!$stat) { print "<strong>ERROR</strong>: Could not access table <strong>".strtoupper($tblname)."</strong>."; } else { /* function print_row($item2,$key) { print ("<td style=\"border-right: solid\" align=\"center\">\n"); echo "$item2\n"; print ("</td>\n"); } */ /*** * * ***** FIXME ********* * The field labels are hardcoded in here. * You have to change the labels for this to work. * ***/ $rows = pg_numrows($stat); /*** * * Setting up google maps specific stuff * * $ids contains the ten ids that you can associate * with locations * * $ imgs lists the image icons that you can have * ***/ $ids=array('A','B','C','D','E','F','G','H','I','J'); $imgs=array('http://libgmail.sourceforge.net/man.png', 'http://libgmail.sourceforge.net/spider.png'); $fh=fopen("gmaps2.xml", "w") or perr("db_xml_create", "unable to create file"); for ($i=0;$i<$rows;$i++) { fprintf($fh, "<location infoStyle=\"geocodeinfo_rfs.xsl\" id=\"%s\">\n", $ids[$i]) or perr("db_xml_create", "Cant fprintf"); $row = array_values(pg_fetch_row($stat,$i)) or perr("db_xml_create", "Cannot retrieve data"); foreach ($rows as $key => $value) { switch($key) { case "latitudedegree": $latdeg=$value; break; case "latitudeminutes": $latmin=$value; break; case "longitudedegree": $longdeg=$value; break; case "longtudeminute": $longmin=$value; break; default: $disp[$key]=$value; } } $lat = $latdeg + ($latmin/60.0); $long = $longdeg + ($longmin/60.0); print("Now printing values into the xml file\n"); fprintf($fh, "<point lat=\"%f\" lng=\"%f\"/>\n", $lat, $long) or perr("db_xml_create", "1"); fprintf($fh, "<icon image=\"%s\" class=\"local\"/>\n", $imgs[0]); fprintf($fh, $str1) or perr("db_xml_create","3"); fprintf($fh, "<info>") or perr("db_xml_create","4"); fprintf($fh, "<title xml:space=\"preserve\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\">\n") or perr("db_xml_create","5"); fprintf($fh, "</title>\n") or perr("db_xml_create","6"); print("Halfway done\n") or perr("db_xml_create","7"); fprintf($fh, "<address>\n") or perr("db_xml_create","8"); fprintf($fh, "<line>Ms. Eva Green</line>\n") or perr("db_xml_create","9"); fprintf($fh, "</address>\n") or perr("db_xml_create","10"); fprintf($fh, "<image>\n") or perr("db_xml_create","11"); fprintf($fh, "http://www.google.co.nz/images/logo_sm.gif\n") or perr("db_xml_create","12"); fprintf($fh, "</image>\n") or perr("db_xml_create","13"); fprintf($fh, "</info>\n") or perr("db_xml_create","14"); } } print("Done with all\n"); pg_close($dbh); fclose($fh); } ?> --- NEW FILE: gmaps.html --- <html> <head> <title>Demo Two for Unofficial Google Maps Embedding How To</title> <script src="http://google.com/maps?file=js&hl=en" type="text/javascript"> </script> <script type="text/javascript"> _mSiteName = 'Richmond Field Station'; _mUsePrintLink=""; function initMap() { // // frb // myMapApp = new _MapsApplication(document.getElementById("container_frb"), document.getElementById("panel"), document.getElementById("metapanel"), document.getElementById("permalink"), document.getElementById("toggle"), document.getElementById("printheader")); myMapApp.loadMap(); /* Note: All XML & XSL files must be on same domain. */ _loadXmlFileFromURL("gmaps.xml", myMapApp); } t.dump = function(a) {alert(a);} //debugging function _loadXmlFileFromURL(url, mapApp) { // // Loads the specified external XML file into the map view. // // frb // // NOTE: URL must be on same domain as page. var _getter = _XMLHttp.create(); _getter.open("GET", url); _getter.onreadystatechange=function() { if (_getter.readyState==4) { mapApp.loadXML(_getter.responseText); } } _getter.send(null); // Whoops, IE *needs* this to be last, Moz is lenient. } </script> <style type="text/css"> #panel table { border:solid 1px grey; width:50%; margin-bottom: 5px; } #panel table td:first-child { width: 24px; } .label { font-size:smaller; font-family:sans-serif; }; </style> </head> <body onload="initMap()"> <!----> <!-- Note: Map height always maximum? --> <div style="position:absolute;left:5px;top:10px;right:5px;border:solid thin grey;"> <div id="container_frb" style="float:right;width:35%;" ></div> <div style="float:left;position:relative;left:10px;width:60%"> <div style="position:absolute;left:0px;top:0px;width:50%;overflow:auto;"> <h1 style="font-family:sans-serif;font-size:medium;">Unofficial Google Maps Embedding How To : Demo Two</h1> <p><tt>_MapsApplication({container div}, {panel div}, {metapanel div}, {permalink div}, {toggle div} | null, {printheader div})</tt></p> <p><dl> <dt style="font-weight:bold;">Container div</dt> <dd>The <tt><div></tt> where the map should be displayed.</dd> <dt style="font-weight:bold;">Panel div</dt> <dd>The <tt><div></tt> where the "sidepanel" should be displayed.</dd> <dt style="font-weight:bold;">Metapanel div</dt> <dd>It appears Gmaps uses this to display error and other messages</dd> <dt style="font-weight:bold;">Permalink div</dt> <dd>It appears Gmaps uses this to display a permanent URL. (Now appears to be required.)</dd> <dt style="font-weight:bold;">Toggle div</dt> <dd>The <tt><div></tt> where the map specification toggle should be displayed. The toggle switches between different map specifications, e.g. Map view and Satellite view. </dd> <dt style="font-weight:bold;">Printheader div</dt> <dd>Presumably displayed at the head of a printed map.</dd> </dl> </p> <p style="font-size:x-small;">-- follower at rancidbacon.com <br /> (Original page: <a href="http://stuff.rancidbacon.com/google-maps-embed-how-to/demo2.html">http://stuff.rancidbacon.com/google-maps-embed-how-to/demo2.html</a>)</p> <p style="font-size:x-small;">26 May 2005<!--25 May 2005--></p> </div> <div style="position:absolute;left:50%;top:5px;width:50%;"> <div id="toggle" style="position:absolute;top:0px:left:10px;font-family:sans-serif;font-size:smaller;"> </div> <div style="position:absolute;top:30px;left:5px;"> <div id="panel" style="height:90%;width:100%;"> </div> <div id="metapanel"></div> <div id="permalink"></div> <div id="printheader"></div> </div> </div> </div> </div> <!-- </body> </html> --- NEW FILE: db_list_databases.php --- <table class="db_schema"> <tr> <td>Database</td> <td>Selected</td> </tr> <?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) { print "<strong>ERROR</strong>: Could not access list of existing databases."; } else { $rows = pg_numrows($stat); 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]; print ("</td>"); print ("<td>"); print ("<input type=radio name=db1 value=\"$data[0]\">"); print ("</td>"); print ("</tr>"); } } pg_close($dbh) or perr("db_list_databases", "Could not close database"); ?> </table> --- NEW FILE: nav_footer.php --- <center> <a href="./index.html">[FireBug home]</a> <a href="./db_admin.php">[DB Admin]</a> <a href="./db_list.php">[DB List]</a> <a href="./db_drop.php">[DB Drop]</a> </center> --- NEW FILE: db_list.php --- <html> <head> <title>Example FireBug Client</title> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <h1>FireBug web client database selection</h1> <hr /> <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> </center> <hr /> <?php include("nav_footer.php"); ?> <p> Database data last updated: <?php echo date ("l dS F Y h:i:s A"); ?> </p> </body> </html> --- NEW FILE: gmaps_update.php --- <?php --- NEW FILE: geocodeinfo_rfs.xsl --- <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates select="location"/> </xsl:template> <xsl:template match="location"> <div style="padding-right: 8px; margin-top: 2px"> <xsl:apply-templates select="info"/> </div> </xsl:template> <xsl:template match="info"> <xsl:variable name="page" select="../@arg0"/> <xsl:variable name="address"> <xsl:for-each select="address/line"> <xsl:if test="position() > 1">, </xsl:if> <xsl:value-of select="."/> </xsl:for-each> </xsl:variable> <div style="font-weight: bold">Custom!</div> <div> <img> <xsl:attribute name="src"> <xsl:value-of select="image"/> </xsl:attribute> </img> </div> <div style="font-size: small; margin-top: 14px"> <xsl:apply-templates select="address/line"/> </div> </xsl:template> <xsl:template match="line"> <div style="margin-top: 2px"><xsl:value-of select="."/></div> </xsl:template> <xsl:template name="getSingleLineAddress"> <xsl:for-each select="address/line"> <xsl:if test="position() > 1">, </xsl:if> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> </xsl:stylesheet> --- NEW FILE: db_drop.php --- <html> <head> <title>Example FireBug Client</title> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <h1>FireBug web client database selection</h1> <center> <form action="db_dropdb.php" method="post"> <table class="db_schema"> <tr> <td>DataBase Name</td> <td>Selected</td> </tr> <?php include("connect.php"); function print_dbname_row($dbname) { print ("<tr><td>"); print $dbname; print ("</td>"); print ("<td>"); print ("<input type=radio name=db1 value=\"$dbname\">"); print ("</td>"); print ("</tr>"); } /** Print only the non-system databases */ $dbh = connect_postgres($defaultdb); $statement = "SELECT DATNAME FROM pg_database where not datname=$defaultdb and not datname='template0'"; $stat = @pg_exec($dbh,$statement); if (!$stat) { print "<strong>ERROR</strong>: Could not access list of databases."; } else { $rows = pg_numrows($stat); for ($i = 0; $i < $rows; $i++) { $data = pg_fetch_row($stat, $i); print_dbname_row($data[0]); } } pg_close($dbh); ?> </table> <input type="submit" value="Drop database"> </form> </center> <hr /> <?php include("nav_footer.php"); ?> <hr /> <p> Database data last updated: <?php echo date ("l dS F Y h:i:s A"); ?> </p> </body> </html> --- NEW FILE: gmaps.xml --- <?xml version="1.0"?> <page> <title>Custom XSL Demo</title> <query>Why?</query> <request/> <center lat="37.9177" lng="-122.332"/> <!-- Original --> <!-- <span lat="0.0179" lng="0.027586"/> --> <span lat="0.002" lng="0.003"/> <overlay panelStyle="sidepanel.xsl"> <location infoStyle="geocodeinfo_rfs.xsl" id="A"> <point lat="37.91" lng="-122.33"/> <icon image="http://libgmail.sourceforge.net/man.png" class="local"/> <info> <title xml:space="preserve" xmlns:xml="http://www.w3.org/XML/1998/namespace"> </title> <address> <line>Mr G. Oogle</line> </address> <image> http://www.google.co.nz/images/logo_sm.gif </image> </info> </location> <location infoStyle="geocodeinfo_rfs.xsl" id="B"> <point lat="37.915" lng="-122.332"/> <icon image="http://maps.google.com/mapfiles/marker.png" class="local"/> <info> <title xml:space="preserve" xmlns:xml="http://www.w3.org/XML/1998/namespace"/> <address> <line>Here be spiders...</line> </address> <image> http://libgmail.sourceforge.net/spider.png </image> </info> </location> <location infoStyle="geocodeinfo_rfs.xsl" id="C"> <point lat="37.91862" lng="-122.3324"/> <icon image="http://maps.google.com/mapfiles/marker.png" class="local"/> <info> <title xml:space="preserve"/> <address> <line>Building 454, Room 124</line> </address> <image> http://libgmail.sourceforge.net/man.png </image> </info> </location> </overlay> </page> --- NEW FILE: firebug.css --- table.db_schema { background-color:#ffff66; border: 3px solid black; align: center; /* width:80%; font-size:75%; */ } h1 { background-color:#ffcc00; color:#ff3300; font-family:tahoma,helvetica,arial; font-size:150%; } h2 { background-color:#ffcc00; color:#ff3300; font-family:tahoma,helvetica,arial; font-size:100%; } h3 { color:#0E37D0; font-family:Georgia; font-weight:bold; font-size:200%; } h4 { /*background-color:#072285;*/ color:#5A7CFC; font-family:Courier New; font-style:normal; font-weight:bold; font-size:150%; } p.jazzy { color:#1841D8; font-family:Comic Sans MS; } p.nice { color:#465BAA; font-family:Lucida Console; } pre.code { background-color:#ffff66; } code.progname { font-weight:bold; } BODY { color:black; background-color:#FFFFF5; } SPAN.title {color:green} SPAN.author {color:purple;} SPAN.publication {color:green} SPAN.fortran { font-variant: small-caps; } span.invisible { color:#FFFFF5; } P.abstract {color:blue; margin-left: 10%; /* width: 80%; */ margin-right: auto; /* background-color: gray; */ } /* a:active { color:red; } a:visited { color:yellow; background-color:blue; } a:link { color:green; } a:hover { color:green; font:bold; } */ /* IMG.inlinemath { text-align: bottom } */ /************************************************/ body { margin:9px 9px 0 9px; padding:0; background-color:#ffffff; } #level0{ background-color:#ffcc00; } #level1 { margin-left:143px; padding-left:9px; background-color:#FFFFFF; } #level2 { background:#FFF3AC; position:relative; } #level3 { margin-right:143px; padding-right:9px; background:#FFFFFF; } #main { background:#fff3ac; } #topBar { background:#ffffff; } #advBar { background:#fff3ac; } #tipDay { float:right; width:175px; background:#FFF3AC; } #lftBar { position:absolute; width:143px; top:9px; left:9px; } #rgtBar { position:absolute; width:143px; top:0; right:0; } --- NEW FILE: hello.php --- <?php print("hello world\n"); ?> --- NEW FILE: db_table_buttons.php --- <form action="db_gmap.php" method="post"> <?php include ("connect.php"); print("Choose different table: "); 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_.*'"; $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); /* for ($i = 0; $i < $rows; $i++) { $data = pg_fetch_row($stat, $i); print ("<input type=hidden name=db1 value=\"$dbname\">"); print ("<input type=submit name=tbl1 value=\"" . $data[0] . "\">"); } */ print ("<input type=hidden name=db1 value=\"$dbname\">"); print ("<input type=submit value=GO>"); print("<select name=tbl1>"); for ($i = 0; $i < $rows; $i++) { $data = pg_fetch_row($stat, $i); print ("<option value=$data[0]> $data[0] </option>"); } print ("<\select>"); } pg_close($dbh); ?> </form> --- NEW FILE: connect.php --- <?php /** Function connect_postgres takes in a database name, and returns the * database handle. Note that the user, host, and port should be adjusted * to match those of the particular postmaster server being used. */ 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; } ?> --- NEW FILE: db_admin.php --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>FireBug database utility script</title> <link rel="SHORTCUT ICON" href="./images/favicon.ico"> <link type="text/css" rel="stylesheet" href="firebug.css"> </head> <body> <h1>FireBug database administration</h1> FireBug logs to a sql database. Since the number of database operations necessary for logging are a limited subset of SQL, we wrap the database administration commands using <a href="http://www.php.net">PHP</a> with an <a href="http://www.apache.org">Apache</a> web server. <hr /> <form action="db_create.php" method="post"> NOTE: Database names are <strong>CASE-INSENSITIVE</strong>. Also, check below for a list of currently known database names that <strong>CANNOT</strong> be used. <br> Database name: <input type="text" name="dbname" /> <br /> Number of motes: <input type="text" name="nummotes"/> <br /> <input type="submit" value="Create database" /> </form> <hr /> <strong>Currently-Known Database Names that are NOT ALLOWED:</strong> <br> and <br> as <br> between <br> in <br> into <br> or <br> select <br> template0 <br> template1 <br> where <br /> <hr /> <?php //$string = system("D:\cygwin\bin\gnuplot.exe < test.gnu"); `D:\cygwin\bin\gnuplot.exe < test.gnu`; include("nav_footer.php"); ?> <!-- --> <img src="../imagetest/test.png"> <!-- --> <hr /> <p> Last Updated: $Date: 2005/06/08 20:45:36 $ by $Author: dantu $. </p> </body> </html> |