home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.pdx.edu
/
2014.02.ftp.ee.pdx.edu.tar
/
ftp.ee.pdx.edu
/
oss
/
cvs-2004
/
bahasa
/
web
/
upload.php,v
< prev
Wrap
Text File
|
2003-10-20
|
10KB
|
549 lines
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: upload.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 to allow an administrator to
// upload an sql file from home and replace the associated
// table if applicable.
//
// 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;
}
$indonesia = new Indonesia();
if ($_SESSION['NODUP_UPLOAD']) {
unset($_SESSION['NODUP_UPLOAD']);
$web->redirect("admin.php");
exit;
}
?>
<html>
<head>
<title>Bahasa Indonesia Dictionary: Upload</title>
<link href="bahasa.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="bahasa.js"></script>
<script language="Javascript" type="text/javascript">
<!--
//////////////////////////////////////////////////////////////////////////////
function get_basename(stoken) {
if (is_white_space(stoken)) {
return(stoken);
}
if (stoken.lastIndexOf("\\") > 0) {
start = stoken.lastIndexOf("\\") + 1;
return(stoken.substring(start, stoken.length));
} else if (stoken.lastIndexOf("/") > 0) {
start = stoken.lastIndexOf("/") + 1;
return(stoken.substring(start, stoken.length));
}
return(stoken);
}
//////////////////////////////////////////////////////////////////////////////
function verify() {
source = document.upload.source.value;
source = trim(source);
if (is_white_space(source)) {
alert(
"You must specify a source file to upload!");
document.upload.source.focus();
return(false);
}
target = document.upload.target.value;
target = trim(target);
if (is_white_space(target)) {
alert(
"You must specify a target value to replace!");
document.upload.target.focus();
return(false);
}
name = document.upload.name.value;
name = trim(name);
if (is_white_space(name)) {
alert(
"You must specify a name value!");
document.upload.name.focus();
return(false);
}
password = document.upload.password.value;
if (is_white_space(password)) {
alert(
"You must specify a password value!");
document.upload.password.focus();
return(false);
}
source_basename = get_basename(source);
if (source_basename != target) {
alert(
"Source and target names do not match! " +
"They must be the same.");
document.upload.source.focus();
return(false);
}
return(true);
}
//////////////////////////////////////////////////////////////////////////////
// -->
</script>
</head>
<body>
<?
$web->show_logo("Upload");
?>
<a href="admin.php">Administration</a>
<br><br>
<?
if (
(isset($_POST['name'])) &&
(isset($_POST['password'])) &&
(isset($HTTP_POST_FILES['source'])) &&
(isset($_POST['target']))) {
$errstr =
$indonesia->login_db_user(
$_POST['name'], $_POST['password']);
if ($errstr != "") {
print "<br><hr><b>${errstr}</b><hr><br>\n";
} else {
$backup_flag = 0;
if ($_POST['backup'] == 1) {
$backup_flag = 1;
}
if ($_POST['replace'] == 1) {
$errstr =
$indonesia->upload_sql_file_and_replace_table(
$HTTP_POST_FILES, $_POST['target'], $backup_flag);
if ($errstr != "") {
print "<br><hr><b>${errstr}</b><hr><br>\n";
} else {
$_SESSION['NODUP_UPLOAD'] = 1;
if ($backup_flag) {
print
"<br><hr><b>\n" .
"SQL file upload and backup " .
"and replace successful!\n" .
"</b><hr><br>\n";
} else {
print
"<br><hr><b>\n" .
"SQL file upload and replace " .
"successful!</b><hr><br>\n";
}
}
} else {
$errstr =
$indonesia->upload_sql_file(
$HTTP_POST_FILES, $_POST['target'], $backup_flag);
if ($errstr != "") {
print "<br><hr><b>${errstr}</b><hr><br>\n";
} else {
$_SESSION['NODUP_UPLOAD'] = 1;
if ($backup_flag) {
print
"<br><hr><b>\n" .
"SQL file upload and backup " .
"successful!</b><hr><br>\n";
} else {
print
"<br><hr><b>\n" .
"SQL file upload " .
"successful!</b><hr><br>\n";
}
}
}
}
} else {
show_upload_form($web, $indonesia);
}
?>
</body>
</html>
<?
//////////////////////////////////////////////////////////////////////////////
function show_upload_form($web, $indonesia) {
$admin_tables = array();
$admin_tables = $indonesia->get_admin_tables();
if (count($admin_tables) < 1) {
return;
}
$table_select =
"<select name=\"target\">\n" .
"<option value=\"\">\n";
foreach($admin_tables as $table) {
$sql = $web->tohtml($table["sql"]);
$table_select
.= "<option value=\"${sql}\">${sql}\n";
}
$table_select .= "</select>\n";
$max_file_size = $indonesia->get_max_file_upload_size();
print <<<EOFSU
<form name="upload" enctype="multipart/form-data" method="post"
action="upload.php" onSubmit='return verify()'>
<table cellpadding="3" cellspacing="3" border="0">
<tr>
<td>Source:</td>
<td>
<input name="source" type="file">
</td>
</tr><tr>
<td>Target:</td>
<td>
$table_select
</td>
</tr><tr>
<td>Name:</td>
<td>
<input type="text" name="name">
</td>
</tr><tr>
<td>Password:</td>
<td>
<input type="password" name="password">
</td>
</tr><tr>
<td>
Create Backup:
</td>
<td>
<input type="checkbox" value="1" name="backup" checked>
</td>
</tr><tr>
<td>
Replace Table:
</td>
<td>
<input type="checkbox" value="1" name="replace">
</td>
</tr><tr>
<td colspan="2" align="right">
<input type="reset" value="Clear form">
<input type="submit" value="Upload!">
</td>
</tr>
</table>
<input type="hidden" name="MAX_FILE_SIZE" value="${max_file_size}">
</form>
<script language="Javascript" type="text/javascript">
document.upload.source.focus();
</script>
EOFSU;
}
//////////////////////////////////////////////////////////////////////////////
function backup_file($web, $indonesia, $file) {
}
//////////////////////////////////////////////////////////////////////////////
function upload_file($web, $indonesia, $source, $target) {
return("");
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
?>
@
1.5
log
@*** empty log message ***
@
text
@d12 1
a12 1
// Modified: October 17, 2003
d62 2
@
1.4
log
@*** empty log message ***
@
text
@d12 1
a12 1
// Modified: October 05, 2003
d63 2
d66 1
a90 25
function is_white_space(stoken) {
if (stoken == null) return(true);
if (stoken == '') return(true);
if (stoken == "") return(true);
return(false);
}
//////////////////////////////////////////////////////////////////////////////
function trim(stoken) {
if (is_white_space(stoken)) {
return(stoken);
}
stoken = stoken.replace(/^\s*/, "");
stoken = stoken.replace(/\s*$/, "");
return(stoken);
}
//////////////////////////////////////////////////////////////////////////////
d163 1
a163 1
//////////////////////////////////////////////////////////////////////////////
@
1.3
log
@*** empty log message ***
@
text
@d12 1
a12 1
// Modified: September 30, 2003
d189 3
a191 1
<h2>Bahasa Indonesia Dictionary: Upload</h2>
@
1.2
log
@*** empty log message ***
@
text
@d12 1
a12 1
// Modified: August 19, 2003
d41 1
a41 1
if (!session_is_registered("ADMIN")) {
d50 1
a50 1
if (session_is_registered("NODUP_UPLOAD")) {
d52 1
a52 1
session_unregister("NODUP_UPLOAD");
d229 1
a229 3
$NODUP_UPLOAD = 1;
session_register("NODUP_UPLOAD");
d260 1
a260 3
$NODUP_UPLOAD = 1;
session_register("NODUP_UPLOAD");
@
1.1
log
@Initial revision
@
text
@d5 34
a38 1
a396 1
@
1.1.1.1
log
@Bahasa Indonesia Dictionary
@
text
@@