📄 setup.php
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>PHPMyEdit Setup</title>
</head>
<style type="text/css">
body {font-family: "Verdana", "Arial", "Sans-Serif"; text-align: left}
h1 {color: #004d9c; font-size: 12pt; font-weight: bold}
h2 {color: #004d9c; font-size: 10pt; font-weight: bold}
h3 {color: #004d9c; font-size: 10pt; }
p {color: #004d9c; font-size: 8pt; }
table {border: 2px solid #004d9c; font-size: 8pt; text-align: center; border-collapse: "collapse"; }
td {border: 2px solid; padding: 2px; color: #004d9c; font-size: 8pt; }
</style>
<body>
<?php
// -- setup.php version 3.5 27-Apr-01
function echo_html($x)
{ echo htmlentities($x)."\n"; }
$self = basename($PHP_SELF);
$dbl = @mysql_pconnect($hn,$un,$pw);
if ((!$dbl) or empty($submit))
{
echo ' <h1>Please log in to your MySQL database</h1>';
if (!empty($submit)) {echo ' <h2>Sorry - login failed - please try again</h2>'."\n";}
echo '
<form action="'.$self.'" method="POST">
<table border="1" cellpadding="1" cellspacing="0" summary="Log in">
<tr>
<td>Hostname:</td>
<td><input type="text" name="hn" value="'.$hn.'"></td>
</tr><tr>
<td>Username:</td>
<td><input type="text" name="un" value="'.$un.'"></td>
</tr><tr>
<td>Password:</td>
<td><input type="password" name="pw" value="'.$pw.'"></td>
</tr>
</table>
<br>
<input type="submit" name="submit" value="Submit">
</form>'."\n";
} else {
if (!isset($db))
{
$dbs = mysql_list_dbs($dbl);
$num_dbs = mysql_numrows($dbs);
echo ' <h1>Please choose a database</h1>
<form action="'.$self.'" method="POST">
<input type="hidden" name="hn" value="'.$hn.'">
<input type="hidden" name="un" value="'.$un.'">
<input type="hidden" name="pw" value="'.$pw.'">
<table border="1" cellpadding="1" cellspacing="1" summary="Choose Database">'."\n";
for ($i=0; $i<$num_dbs; $i++)
{
$db = mysql_dbname($dbs, $i);
if ($i==0)
{echo ' <tr><td><input checked type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n"; }
else {echo ' <tr><td><input type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n";}
}
echo ' </table>
<br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>'."\n";
} else {
if (!isset($tb))
{
echo ' <h1>Please choose a table from database: '.$db.'</h1>
<form action="'.$self.'" method="POST">
<input type="hidden" name="hn" value="'.$hn.'">
<input type="hidden" name="un" value="'.$un.'">
<input type="hidden" name="pw" value="'.$pw.'">
<input type="hidden" name="db" value="'.$db.'">
<table border="1" cellpadding="1" cellspacing="1" summary="Choose Table">'."\n";
$tbs = mysql_list_tables($db,$dbl);
$num_tbs = @mysql_numrows($tbs);
for ($j=0; $j<$num_tbs; $j++)
{
$tb = mysql_tablename($tbs, $j);
if ($j==0)
{echo ' <tr><td><input checked type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n"; }
else {echo ' <tr><td><input type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n";}
}
echo ' </table>
<br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>'."\n";
} else {
if (!isset($id))
{
echo ' <h1>Please choose an identifier from table: '.$tb.'</h1>
<h2>This field will be used in Changes or Deletes.</h2>
<p>
It must be numeric and must uniquely identify a record.<br>
If you haven\'t got a suitable field select <i>None</i>.
</p>
<form action="'.$self.'" method="POST">
<input type="hidden" name="hn" value="'.$hn.'">
<input type="hidden" name="un" value="'.$un.'">
<input type="hidden" name="pw" value="'.$pw.'">
<input type="hidden" name="db" value="'.$db.'">
<input type="hidden" name="tb" value="'.$tb.'">
<table border="1" cellpadding="1" cellspacing="1" summary="Choose Key">
<tr><td><input type="radio" name="id" value="">
<td><i>None</i></td><td><i>No id field required</i></td></tr>'."\n";
$fds = mysql_list_fields($db,$tb,$dbl);
$j=0;
while (1)
{
$fd = @mysql_field_name($fds, $j);
if ($fd == "") { break; }
$ff = mysql_field_flags($fds, $j);
if (stristr($ff,"primary_key"))
{echo " <tr><td><input checked type=\"radio\" name=\"id\" value=\"".$fd."\"></td><td>".$fd."</td><td>".$ff."</td>"; }
else {echo " <tr><td><input type=\"radio\" name=\"id\" value=\"".$fd."\"></td><td>".$fd."</td><td>".$ff."</td>"; }
echo "</tr>\n";
++$j;
}
echo ' </table>
<br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>'."\n";
} else {
echo '<h1>Here is your PGPMyEdit calling program</h1>'."\n";
echo '<h2>You may now copy and paste it into your PHP editor</h2>'."\n";
echo '<hr><pre>'."\n";
echo_html('<?php echo(\'<?xml version="1.0"?>\'."\n")?>');
echo_html('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>'.$tb.'</title>
<link type="text/css" href="'.$tb.'.css" rel="stylesheet" />
</head>
<body>
<div class="main">
<h3>'.$tb.'</h3>
<?php
// MySQL host name, user name, password, database, and table to edit
$hn=\''.$hn.'\';
$un=\''.$un.'\';
$pw=\''.$pw.'\';
$db=\''.$db.'\';
$tb=\''.$tb.'\';
// Name of field which is the unique key
$key=\''.$id.'\';
// Type of key field (int/real/string/date etc)');
if ($id=="")
{
echo_html("$key_type='';");
} else {
$fds = mysql_list_fields($db,$tb,$dbl);
$j=0;
while (1)
{
$fd = @mysql_field_name($fds, $j);
if ($fd == '') { break; }
if ($fd == $id)
{
echo_html('$key_type=\''.@mysql_field_type($fds, $j).'\';');
break;
}
++$j;
}
}
echo_html('// Number of records to display on the screen
$inc = 15;
// Options you wish to give the users - A(dd) C(hange) D(elete) F(ilter)
// I(nitial sort suppressed)
$options = \'ACDF\';
// Number of lines to display on multiple selection filters
$multiple = \'4\';
//
// Field definitions. Fields will be displayed left to right
// on the screen in the order in which they appear in this list.
// [\'name\'] is the title used for column headings, etc.;
// [\'width\'] is an optional display width specification for the column,
// e.g. [\'width\'] = \'100px\';
// [\'format\'] is optional for date fields only to specify sequence
// and delimiter for day, month, year; e.g. for 25 April 2001:
// [\'format\']=\'mdy/\' would give \'04/25/01\' and
// [\'format\']=\'dmy.\' would give \'25.04.01\'
// [\'sort\'] = true means the users may sort the display on this column;
// [\'URL]\' is used to make a field \'clickable\' in the display,
// e.g. [\'URL\'] = \'mailto:\' or [\'URL\'] = \'http://\';
// [\'required\'] = true will generate javascript to prevent null entries
// by users
// [\'options\'] is an optional parameter to control whether a field is
// displayed in the A(dd), C(hange), D(elete), or L(ist) views
// [\'textarea\'][\'rows\'] and/or [\'textarea\'][\'cols\'] specifies a
// textarea is to be used to give multi-line input,
// e.g. [\'textarea\'][\'rows\'] = 5; [\'textarea\'][\'cols\'] = 10
// [\'values\'] restricts user input to the specified constants,
// e.g. [\'values\'] = array(\'A\',\'B\',\'C\')
// [\'values\'][\'table\'] and [\'values\'][\'column\'] restricts user
// input to the values found in the specified column of another table.
// If the optional [\'values\'][\'description\'] is also specified,
// the values displayed to the user by PHPMyEdit will be taken from the
// column specified by \'description\'.
// e.g. [\'values\'][\'table\']=\'mytable\'
// [\'values\'][\'column\']=\'key_column\'
// [\'values\'][\'description\']=\'result_column\' /*optional*/
// [\'select\'] = \'T/D/M\' (text, drop-down, or multiple selection for filters)
//');
$fds = mysql_list_fields($db, $tb, $dbl);
$num_fds = mysql_num_fields($fds);
for ($k=0 ; $k<$num_fds; $k++)
{
$fd = mysql_field_name($fds,$k);
$fn = ucwords(strtr($fd,"_-."," "));
echo_html('$fdd[\''.$fd.'\'][\'name\'] = \''.$fn.'\';');
echo_html('$fdd[\''.$fd.'\'][\'sort\'] = true;');
echo_html('$fdd[\''.$fd.'\'][\'select\'] = \'T\';');
if (stristr(mysql_field_flags($fds,$k),'not_null')) {
echo_html('$fdd[\''.$fd.'\'][\'required\'] = true;');
}
if (mysql_field_type($fds,$k)=='blob')
{
echo_html('$fdd[\''.$fd.'\'][\'textarea\'][\'rows\'] = 5;');
echo_html('$fdd[\''.$fd.'\'][\'textarea\'][\'cols\'] = 50;');
}
if (mysql_field_type($fds,$k)=='date')
{
echo_html('$fdd[\''.$fd.'\'][\'format\'] = \'dmy/\';');
}
}
echo_html('// and now the all-important call to PHPMyEdit');
echo_html('// warning - beware of case-sensitive operating systems!');
echo_html('require \'PHPMyEdit.inc\';');
echo_html('$labels=array(\'Prev\',\'Add\',\'Change\',\'Delete\',\'Next\',\'Page\',\'Records\',
\'Save\',\'More\',\'Cancel\',\'record added\',\'record changed\',\'record deleted\',\'Please enter\');');
echo_html('$MyForm = new PHPMyEdit ($hn, $un, $pw, $db, $tb, $key, $key_type, $inc, $options,
$multiple, $fdd, $labels);');
echo_html('$MyForm -> execute();
?>
</div>
</body>
</html>');
echo "</pre><hr>\n";
}
}
}
}
?>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -