<?php
/* updatecust.php
** Stuff updated cust data into db
*****
** SVN revision info
** $Date: 2010-05-11 18:56:06 +0000 (Tue, 11 May 2010) $
** SVN revision $Rev: 398 $
** Last update by $Author: kdeugau $
*****
** Copyright (C) 2006 - Kris Deugau
*/

  $db_conn = pg_connect("dbname=ipdb user=ipdb password=ipdbpwd");

  if (!$db_conn) {
    echo ("<H1>Failed connection to db ipdb.  Can't continue.</H1>");
    exit;
  }

  $custid = $_REQUEST['custid'];
  if (isset($_REQUEST['deletecust'])) {
    print "<html><head><title>Deleting $custid from WHOIS</title></head><body>\n".
	"<h2>Deleting $custid from WHOIS</h2>\n".
	"<a href=\"/ip/cgi-bin/admin.cgi\">Back</a> to admin<br>\n".
	"<a href=\"/ip/cgi-bin/list-cust.php\">Back</a> to WHOIS customer list\n";
    $qu = pg_exec ("DELETE FROM customers WHERE custid='$custid'");
    if (!$qu) {
      print "Error deleting $custid.  Mail Kris.\n";
    }
    print "</body></html>\n";
    exit;
  }
?>
<html><head>
<title>[IPDB admin] Updating WHOIS data</title>
</head>
<body>
<h2>Updating WHOIS data for <? print $custid; ?></h2>
<a href="/ip/cgi-bin/admin.cgi">Back</a> to admin<br>
<a href="/ip/cgi-bin/list-cust.php">Back</a> to WHOIS customer list
<?

// snag form data into local vars.  Not being excessively paranoid because we're
// buried deep and this is a hack anyway.

  $name = $_REQUEST['name'];
  $addr1 = $_REQUEST['addr1'];
  $addr2 = $_REQUEST['addr2'];
  $city = $_REQUEST['city'];
  $prov = $_REQUEST['prov'];
  $country = $_REQUEST['country'];
  $pocode = $_REQUEST['pocode'];
  $phone = $_REQUEST['phone'];
  $tech = $_REQUEST['tech'];
  $abuse = $_REQUEST['abuse'];
  $admin = $_REQUEST['admin'];
  $rdns = $_REQUEST['rdns'];
  $special = $_REQUEST['special'];

  $qu = pg_exec ($db_conn, "UPDATE customers SET name='$name',street='$addr1',street2='$addr2',".
		"city='$city',province='$prov',country='$country',pocode='$pocode',phone='$phone',".
		"tech_handle='$tech',abuse_handle='$abuse',admin_handle='$admin',".
		"def_rdns='$rdns',special='$special' WHERE custid='$custid'");

  echo "<table border=2 cellpadding=2>".
	"<tr><td align=right>CustID</td><td>$custid</td></tr>\n".
	"<tr><td>Name</td><td>$name</td></tr>\n".
	"<tr><td>Street address</td><td>$addr1</td></tr>\n".
	"<tr><td>Address 2</td><td>$addr2</td></tr>\n".
	"<tr><td>City</td><td>$city</td></tr>\n".
	"<tr><td>Province</td><td>$prov</td></tr>\n".
	"<tr><td>Country</td><td>$country</td></tr>\n".
	"<tr><td>Postal code</td><td>$pocode</td></tr>\n".
	"<tr><td>Phone</td><td>$phone</td></tr>\n".
	"<tr><td>Tech handle</td><td>$tech</td></tr>\n".
	"<tr><td>Abuse handle</td><td>$abuse</td></tr>\n".
	"<tr><td>Admin handle</td><td>$admin</td></tr>\n".
	"<tr><td>Default rDNS</td><td>$rdns</td></tr>\n".
	"<tr><td>\"Special\"</td><td><pre>$special</pre></td></tr>\n".
	"</table>\n";

?>
</body>
</html>
