head 1.13;
access;
symbols
Initial:1.1.1.1 bule:1.1.1;
locks; strict;
comment @# @;
1.13
date 2003.10.26.01.53.10; author bule; state Exp;
branches;
next 1.12;
1.12
date 2003.10.20.00.21.45; author bule; state Exp;
branches;
next 1.11;
1.11
date 2003.10.18.00.33.41; author bule; state Exp;
branches;
next 1.10;
1.10
date 2003.10.06.00.39.26; author bule; state Exp;
branches;
next 1.9;
1.9
date 2003.10.01.06.51.29; author bule; state Exp;
branches;
next 1.8;
1.8
date 2003.09.04.07.27.00; author bule; state Exp;
branches;
next 1.7;
1.7
date 2003.09.02.07.07.24; author bule; state Exp;
branches;
next 1.6;
1.6
date 2003.08.31.00.02.48; author bule; state Exp;
branches;
next 1.5;
1.5
date 2003.08.30.00.33.38; author bule; state Exp;
branches;
next 1.4;
1.4
date 2003.08.30.00.31.53; author bule; state Exp;
branches;
next 1.3;
1.3
date 2003.08.28.20.04.48; author bule; state Exp;
branches;
next 1.2;
1.2
date 2003.08.19.19.05.16; 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.13
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: insert.php
// Author(s): John L. Whiteman
// Created: June 23, 2003
// Modified: October 25, 2003
// Description: The purpose of this restricted access PHP web
// client page is allow an administrator to insert
// new entries into the dictionary table of the
// database. This page also works with misses.php
// and requests.php regarding new inserts.
//
// 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();
$status = $indonesia->get_dictionary_status();
if ($status["status"] == 1 || $status["status"] == 2) {
$web->redirect("admin.php");
exit;
}
$title = "";
$insert_flag = -1;
if (isset($_GET['insert_missed_entry'])) {
$title = "Insert Missed Entry";
$insert_flag = 0;
} else if (isset($_GET['insert_requested_entry'])) {
$title = "Insert Requested Entry";
$insert_flag = 1;
} else if (
(isset($_POST['insert_new_entry'])) &&
(isset($_POST['language']))) {
$title = "Insert New $_POST[language] Entry";
$insert_flag = 2;
} else {
$title = "Insert New Entry";
$insert_flag = 3;
}
?>
Bahasa Indonesia Dictionary: echo "$title"; ?>
$web->show_logo("$title");
?>
Administration
|
Search
if ($insert_flag == 0) {
print
"\n";
} else if ($insert_flag == 1) {
print
"\n";
} else if ($insert_flag == 2) {
print
"\n";
}
if (
($_SESSION['NODUP_INSERT_ENTRY']) &&
(isset($_POST['id'])) &&
($_SESSION['NODUP_INSERT_ENTRY'] == $_POST['id'])) {
show_insert_new_form($web, $indonesia);
//HERE WE DO A NEW INSERT FROM A WORD SUBMITTED BY EITHER misses.php or
//requests.php
} else if (
(isset($_POST['english'])) &&
(isset($_POST['indonesian'])) &&
(isset($_POST['pos'])) &&
(isset($_POST['id'])) &&
(isset($_POST['spelling_flag'])) &&
(isset($_POST['new_insert']))) {
$rc = insert($web, $indonesia,
$_POST['english'], $_POST['indonesian'],
$_POST['pos'], $_POST['spelling_flag'],
$_POST['pronunciation'], $_POST['pronunciation_ipa'],
$_POST['comments']);
if (!$rc) {
$_SESSION['NODUP_INSERT_ENTRY'] = $_POST['id'];
}
show_insert_new_form($web, $indonesia);
//HERE WE DO AN UPDATE OF EXISTING WORD
} else if (
(isset($_POST['english'])) &&
(isset($_POST['indonesian'])) &&
(isset($_POST['pos'])) &&
(isset($_POST['id'])) &&
(isset($_POST['spelling_flag'])) &&
(isset($_POST['replace_insert']))) {
$pkey = $_POST['replace_insert'];
$rc =
replace(
$web, $indonesia, $pkey,
$_POST['english'], $_POST['indonesian'],
$_POST['pos'], $_POST['spelling_flag'],
$_POST['pronunciation'], $_POST['pronunciation_ipa'],
$_POST['comments']);
if (!$rc) {
$_SESSION['NODUP_INSERT_ENTRY'] = $_POST['id'];
}
show_insert_new_form($web, $indonesia);
//HERE WE DO A NEW INSERT
} else if (
(isset($_POST['english'])) &&
(isset($_POST['indonesian'])) &&
(isset($_POST['pos'])) &&
(isset($_POST['id'])) &&
(isset($_POST['spelling_flag'])) &&
(isset($_POST['password']))) {
$errstr = $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
if ($errstr != "") {
print "Permission denied!\n";
} else {
$delete_flag = "";
if (isset($_POST['delete_miss'])) {
$delete_flag =
"";
} else if (isset($_POST['delete_request'])) {
$delete_flag =
"";
}
$dups =
check_for_duplicates(
$web, $indonesia, $_POST['english'], $_POST['indonesian'],
$_POST['pos'], $_POST['spelling_flag'],
$_POST['pronunciation'], $_POST['pronunciation_ipa'],
$_POST['comments'], $_POST['id'], $delete_flag);
if ($dups == 0) {
$rc = insert($web, $indonesia,
$_POST['english'], $_POST['indonesian'],
$_POST['pos'], $_POST['spelling_flag'],
$_POST['pronunciation'], $_POST['pronunciation_ipa'],
$_POST['comments']);
if (!$rc) {
$_SESSION['NODUP_INSERT_ENTRY'] = $_POST['id'];
show_insert_new_form($web, $indonesia);
}
}
}
} else {
if ($insert_flag == 0) {
show_insert_missed_form(
$web, $indonesia, $_GET['insert_missed_entry']);
} else if ($insert_flag == 1) {
show_insert_request_form(
$web, $indonesia, $_GET['insert_requested_entry']);
} else if ($insert_flag == 2) {
show_dictionary_editor_form(
$web, $indonesia, $_POST['insert_new_entry'],
$_POST['language']);
} else {
show_insert_new_form($web, $indonesia);
}
}
?>
//////////////////////////////////////////////////////////////////////////////
function check_for_duplicates(
$web, $indonesia, $english, $indonesian, $pos, $spelling_flag,
$pronunciation, $pronunciation_ipa, $comments, $id, $delete_flag="") {
$duplicates = array();
$english = $web->strip($english);
$indonesian = $web->strip($indonesian);
$pos = $web->strip($pos);
$spelling_flag = $web->strip($spelling_flag);
$pronunciation = $web->strip($pronunciation);
$pronunciation_ipa = $web->strip($pronunciation_ipa);
$comments = $web->strip($comments);
$id = $web->strip($id);
$hidden =
"\n" .
"\n" .
"\n" .
"\n" .
"\n" .
"\n" .
"\n" .
"\n" .
"${delete_flag}\n";
$errstr =
$indonesia->check_for_duplicate_entries(
$duplicates, $english, $indonesian, $pos, $spelling_flag);
if ($errstr != "") {
print " ${errstr} \n";
return(0);
}
$dup_count = count($duplicates);
if ($dup_count == 0) {
return(0);
}
$english = $web->tohtml($english);
$indonesian = $web->tohtml($indonesian);
$pos = $web->tohtml($pos);
$spelling_flag = $web->tohtml($spelling_flag);
$pronunciation = $web->tohtml($pronunciation);
$pronunciation_ipa = $web->tohtml($pronunciation_ipa);
$comments = $web->tohtml($comments);
$parts_of_speech = array();
$errstr = $indonesia->get_pos($parts_of_speech, 0);
$poss = $parts_of_speech[$pos];
$spelling = "Modern";
if ($spelling_flag == 1) {
$spelling = "Pre 1972";
}
$commentss = $comments;
if ($commentss == "") {
$commentss = "N/A";
}
print
"Found ${dup_count} exact and/or similar " .
"existing entries in the dictionary database!\n";
print
"\n";
print
"\n";
print
"
\n";
for ($i = 0; $i < $dup_count; $i++) {
if ($i == 0) {
print
"