require_once( "./mwin.php" );
?>
PHP 雛形
if ( $_GET['type'] == '' ) {
print mystr( "テーブルを選択するかクエリーを実行して下さい" );
exit();
}
// 接続とDB選択
$link = mysql_connect($host, $user, $pass);
if ( !$link ) {
print mystr( "接続エラー" );
exit();
}
mysql_select_db( $db, $link );
// SQL の指定
if ( $_GET['type'] == '1' ) {
$sql = "select * from `" . todbstr($_GET['table']) . "`";
}
if ( $_GET['type'] == '2' ) {
$sql = todbstr($_GET['text']);
if ( $mode == "user" ) {
foreach ( $out_command as $value ) {
if ( stristr( $sql, $value ) ) {
print mystr( "処理する権限がありません" );
exit();
}
}
}
}
if ( $_GET['type'] == '3' ) {
$sql = "SHOW COLUMNS FROM `" . todbstr($_GET['table']) . "`";
}
$result = mysql_query($sql);
if ( $result === TRUE ) {
print mystr( "処理は実行されました
" );
print $_GET['text'] . "
";
exit();
}
// SQL のエラー処理
if (!$result) {
print mystr( "SQLエラー
" );
print dbstr(mysql_error());
exit();
}
// 一覧作成
$nField = mysql_num_fields( $result );
print "\n";
print "\n";
print " | \n";
for( $i = 0; $i < $nField; $i++ ) {
$name = mysql_field_name ( $result, $i );
print " " . dbstr($name) . " | \n";
}
print "
\n";
$nCount = 0;
while ($row = mysql_fetch_row($result)) {
print "\n";
print " | " . ($nCount + 1) . " | \n";
for( $i = 0; $i < $nField; $i++ ) {
print " " . dbstr($row[$i]) . " | \n";
}
print "
\n";
$nCount++;
if ( $nCount >= $data_limit ) {
break;
}
}
print "
";
mysql_free_result($result);
// 接続解除
mysql_close($link);
?>