cvs: php-hosts-web /clients host-services-edit.php /include shared.inc
| From: | jim winstead | Date: | Sun, 21 Apr 2002 23:49:22 +0000 |
| Subject: | cvs: php-hosts-web /clients host-services-edit.php /include shared.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-9731@lists.php.net to get a copy of this message | ||
jimw Sun Apr 21 19:49:22 2002 EDT
Modified files:
/php-hosts-web/clients host-services-edit.php
/php-hosts-web/include shared.inc
Log:
finish putting freeform fields into database
Index: php-hosts-web/clients/host-services-edit.php
diff -u php-hosts-web/clients/host-services-edit.php:1.3
php-hosts-web/clients/host-services-edit.php:1.4
--- php-hosts-web/clients/host-services-edit.php:1.3 Sun Apr 21 18:17:58 2002
+++ php-hosts-web/clients/host-services-edit.php Sun Apr 21 19:49:22 2002
@@ -1,12 +1,8 @@
-<?
-require ("shared.inc");
+<?php
+require 'shared.inc';
require 'login.inc';
-commonHeader("Edit Host Service");
-?>
-<h3>Edit Host Services</h3>
-
-<?
+commonHeader("Edit Host Service");
if ($MODE=="EDIT") {
@@ -100,8 +96,9 @@
$hostid = $argv[0];
- $query = "select * from $HOST_SERVICES_TABLE where HostID=" . $hostid;
- $q1 = mysql_db_query($DBASE,$query) or die ("\"$query\" is a bad query.");
+ $query = "SELECT * FROM $HOST_SERVICES_TABLE WHERE HostID=$hostid";
+ $q1 = mysql_query($query)
+ or die ("\"$query\" is a bad query.");
unset($THIS);
while ($result=mysql_fetch_array($q1)) {
@@ -118,18 +115,15 @@
mysql_free_result($q1);
- $query = "select * from $HOSTS_TABLE where HostID=" . $hostid;
- $q1 = mysql_db_query($DBASE,$query) or die ("\"$query\" is a bad query.");
- $hostname = mysql_result($q1,0,"HostName");
-
+ $hostname = mysql_get_one("SELECT HostName FROM $HOSTS_TABLE WHERE HostId=$hostid");
?>
Here are all the services tracked in this directory. Add or edit those offered by
<B><? qecho($hostname); ?><B>:
-<FORM METHOD="post" ACTION="host-services-edit.php">
+<form method="post" action="host-services-edit.php">
<INPUT TYPE="hidden" NAME="MODE" value="EDIT">
-<INPUT TYPE="hidden" NAME="hostid" value=<? echo $hostid; ?>>
+<input type="hidden" name="hostid" value="<?php echo
$hostid?>">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5>
<TR VALIGN=top BGCOLOR="<? echo $COLOR["ltpurple"]; ?>">
@@ -239,8 +233,8 @@
break;
case "free":
echo "<TEXTAREA NAME=\"value_" . $sid . "\" COLS=30 ROWS=5
WRAP=virtual>";
- $file = $DESC_DIR . "/h" . $hostid . "s" . $sid;
- showFile($file,"");
+ $query = "SELECT content FROM host_value WHERE HostId=$hostid AND ServiceId=$sid";
+ echo htmlentities(mysql_get_one($query));
echo "</TEXTAREA>";
break;
}
Index: php-hosts-web/include/shared.inc
diff -u php-hosts-web/include/shared.inc:1.3 php-hosts-web/include/shared.inc:1.4
--- php-hosts-web/include/shared.inc:1.3 Sun Apr 21 18:12:36 2002
+++ php-hosts-web/include/shared.inc Sun Apr 21 19:49:22 2002
@@ -5,8 +5,6 @@
$ROOT_URL = "http://hosts.php.net";
$ROOT_DIR = $DOCUMENT_ROOT;
-$DESC_DIR = $ROOT_DIR . "/desc";
-
$CC_FILE = $ROOT_DIR . "/include/country_codes.inc";
require($CC_FILE);
@@ -16,6 +14,10 @@
}
$DBASE = "phphosts";
+
+mysql_select_db('phphosts')
+ or die ("unable to select database: ".mysql_error());
+
$HOSTS_TABLE = "hosts";
$USERS_TABLE = "users";
$HOST_SERVICES_TABLE = "host_services";
@@ -29,10 +31,10 @@
function mysql_get_one($query) {
$res = mysql_query($query);
- if (!$res) {
- return false;
+ if ($res && mysql_num_rows($res)) {
+ return mysql_result($res,0);
}
- return mysql_result($res,0);
+ return false;
}
function qecho($stuff) {
@@ -40,22 +42,6 @@
}
-function showFile($filename, $end="\n") {
- $i=0;
- if (file_exists($filename)) {
- $x=file($filename);
- while($i<count($x)) {
- $text=$x[$i];
- echo $text.$end;
- $i++;
- }
- return($i);
- } else {
- return FALSE;
- }
-}
-
-
function move($oldfile,$newfile) {
copy($oldfile,$newfile);
unlink($oldfile);