head 1.6;
access;
symbols
Initial:1.1.1.1 bule:1.1.1;
locks; strict;
comment @# @;
1.6
date 2003.10.20.00.21.46; author bule; state Exp;
branches;
next 1.5;
1.5
date 2003.10.18.00.33.42; author bule; state Exp;
branches;
next 1.4;
1.4
date 2003.10.06.00.39.27; author bule; state Exp;
branches;
next 1.3;
1.3
date 2003.10.01.06.51.30; author bule; state Exp;
branches;
next 1.2;
1.2
date 2003.08.19.19.24.21; author bule; state Exp;
branches;
next 1.1;
1.1
date 2003.08.12.19.18.23; author bule; state Exp;
branches
1.1.1.1;
next ;
1.1.1.1
date 2003.08.12.19.18.23; author bule; state Exp;
branches;
next ;
desc
@@
1.6
log
@*** empty log message ***
@
text
@
session_start();
require_once("../php/Indonesia.php");
require_once("../php/Web.php");
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Project Name: Bahasa Indonesia Dictionary
// Directory: bahasa/web
// File Name: sql.php
// Author(s): John L. Whiteman
// Created: June 23, 2003
// Modified: October 19, 2003
// Description: The purpose of this restricted access PHP web
// client page is allow an administrator to run
// custom SQL commands against the database.
//
// Copyright (c) 2003 John L. Whiteman
//
// Permission is herby granted, free of charge, to any person obtaining a
// copy of this software, data, and associated documentation files
// (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
$web = new Web();
if (!$_SESSION['ADMIN']) {
$web->redirect("login.php");
exit;
}
if ($_SESSION['NODUP_SQL']) {
unset($_SESSION['NODUP_SQL']);
$web->redirect("admin.php");
exit;
}
$indonesia = new Indonesia();
$status = $indonesia->get_dictionary_status();
if ($status["status"] == 1 || $status["status"] == 2) {
$web->redirect("admin.php");
exit;
}
?>
Bahasa Indonesia Dictionary: SQL
$web->show_logo("SQL");
?>
Administration
show_sql_form($web, $indonesia);
if (
(isset($_POST['statement'])) &&
(isset($_POST['name'])) &&
(isset($_POST['password']))) {
run_sql(
$web, $indonesia, $_POST['statement'],
$_POST['name'], $_POST['password']);
}
?>
//////////////////////////////////////////////////////////////////////////////
function run_sql($web, $indonesia, $statement, $name, $password) {
$results = array();
$name = trim($name);
if ($name == "") {
print
" You must provide a name value! \n";
return;
}
$password = trim($password);
if ($password == "") {
print
" You must provide a password value! \n";
return;
}
$statement = trim($statement);
if ($statement == "") {
print
" You must provide an SQL value! \n";
return;
}
$errstr =
$indonesia->login_db_user($name, $password);
if ($errstr != "") {
print " ${errstr} \n";
return;
}
$errstr = $indonesia->open_dictionary();
if ($errstr != "") {
print " ${errstr} \n";
return;
}
$statement = stripslashes($statement);
$rows = mysql_query($statement);
$errstr = mysql_error();
if ($errstr != "") {
print " ${errstr} \n";
return;
}
if (preg_match("/delete/i", "$statement")) {
$arows = mysql_affected_rows();
print
" Affected Deleted Rows: ${arows} \n";
return;
}
if (preg_match("/update/i", "$statement")) {
$arows = mysql_affected_rows();
print
" Affected Updated Rows: ${arows} \n";
return;
}
$nrows = mysql_num_rows($rows);
if (!$nrows) {
return;
}
$count = mysql_num_fields($rows);
$table =
"