if ($auth->auth["uid"] == "nobody") {
    printUsage();
} else {
    buttons();
}
?>
	</td>
</tr>
<tr>
	<td valign="top"><strong><?php 
print T_("Antonym:");
?>
</strong></td>
	<td>
	<?php 
$antonym_array = getAntonym($db, uservar('wmid'));
$antonym_word = "";
if (is_array($antonym_array)) {
    list($antonym_mid, $antonym_word, $antonym_wmid) = $antonym_array;
}
if (isset($_POST['antonym']) && $antonym_word == "") {
    $antonym_word = escape($_POST['antonym']);
}
if ($disambiguate != "") {
    print "<span class=\"error\">" . T_("Please disambiguate your input:") . "</span><br /><br />";
    print $disambiguate;
} else {
    if ($antonym_word != "") {
        if ($auth->auth["uid"] == "nobody") {
            print $antonym_word . ", ";
        } else {
</form>

<?php 
include "../include/baseforms.php";
?>

<?php 
include "../include/levenshtein.php";
?>

<?php 
include "../include/substring_matches.php";
?>

<?php 
if (uservar('word') && trim(uservar('word')) != "") {
    ?>
	<p><a href="add.php?word=<?php 
    print urlencode($_GET['word']);
    ?>
"><?php 
    print sprintf(_("Add '%s' and synonyms to the thesaurus"), escape($_GET['word']));
    ?>
</a></p>
<?php 
}
?>

<script type="text/javascript">
<!--
	document.f.word.focus();
$cancel_login = 1;
page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Default_Auth"));
include "../include/tool.php";
$db = new DB_Thesaurus();
$word = $_GET['word'];
$title = sprintf(_("Matches for '%s'"), escape($word));
$stop_robots = 1;
include "../include/top.php";
?>

<?php 
include "../include/synsets.php";
?>

<?php 
if (uservar('word')) {
    $i = 0;
    foreach ($word_ids as $word_id) {
        ?>
		<a href="add.php?id=<?php 
        print $word_id;
        ?>
"><?php 
        print sprintf(_("Add another meaning of '%s' to the thesaurus"), escape($words[$i]));
        ?>
</a><br />
		<?php 
        $i++;
    }
    if (!in_array($word, $words)) {
        ?>
<?php

include "../../include/phplib/prepend.php3";
page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth"));
include "../../include/tool.php";
$db = new DB_Thesaurus();
if ($auth->auth['uname'] != 'admin') {
    print "Access denied.";
    return;
}
if (!uservar('id')) {
    print "Error: no meaning_id";
    return;
}
### Remove (=hide) the synset:
$query = sprintf("UPDATE meanings\n\tSET hidden = 1\n\tWHERE id = %d", uservar('id'));
$db->query($query);
header("HTTP/1.0 204 No Content");
    $db->next_record();
    ?>
		<td valign="top">
			<?php 
    print $db->f('word');
    ?>
			<input type="hidden" name="word" value="<?php 
    print $db->f('word');
    ?>
">
		</td>
	<?php 
} else {
    ?>
		<td valign="top"><input size="25" maxlength="50" type="text" name="word" value="<?php 
    print escape(uservar('word'));
    ?>
" /></td>
		<td valign="top">
			<?php 
    if (!getvar('id')) {
        ?>
				<?php 
        print _("A new synset -- i.e. a new meaning -- will be started with this word.");
        ?>
			<?php 
    }
    ?>
		</td>
	<?php 
}
        return;
    }
}
function generatePassword($length)
{
    // generate a random password:
    list($usec, $sec) = explode(' ', microtime());
    mt_srand((double) $sec + (double) $usec * 100000);
    $possible_characters = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $string = "";
    while (strlen($string) < $length) {
        $string .= substr($possible_characters, mt_rand(0, 62) % strlen($possible_characters), 1);
    }
    return $string;
}
$title = T_("Register");
include "include/top.php";
?>

<p><?php 
print sprintf(T_("Thanks for registering. The password will be sent to <span class='inp'>%s</span>."), escape(uservar('email')));
?>
</p>

<p><a href="./"><?php 
print T_("Back to homepage");
?>
</a></p>

<?php 
include "include/bottom.php";
$page = "get_delete_comment";
$title = _("Comment on the deletion");
include "../include/top.php";
?>

<form action="do_save.php" method="post" name="commentform">
<input type="hidden" name="do_remove" value="1" />
<input type="hidden" name="meaning_id" value="<?php 
print intval(uservar('meaning_id'));
?>
" />

<table cellpadding="0" cellspacing="2" border="0">
<tr>
	<td colspan="2"><?php 
print sprintf(_("Please add a short comment that explains why the synset <span class='inp'>%s</span> can be deleted:"), join(', ', getSynset(uservar('meaning_id'))));
?>
</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
	<td><?php 
print _("Short comment:");
?>
</td>
	<td><input size="50" type="text" name="comment" value="" /></td>
</tr>
<tr>
	<td></td>
	<td align="right"><?php 
print "<input type=\"submit\" value=\"" . _("Send") . "\" />";
    $synset = getSynsetWithUsage($db->f('meaning_id'), 1);
    $subject = getSubject($db->f('meaning_id'));
    $subject_str = "";
    if ($subject != "") {
        $subject_str = "[" . $subject . "]";
    }
    $synset_str = join(', ', $synset);
    $word_regexp = preg_quote($word, '/');
    # \b doesn't react on German special characters etc. so we use
    # "[\s,!?.]" as a workaround - we first needs to add whitespace
    # because the workaround wouldn't match start and end:
    $synset_str = " " . $synset_str . " ";
    $synset_str = preg_replace("/([\\s,!?.])({$word_regexp})([\\s,!?.])/i", "\$1<strong>\$2</strong>\$3", $synset_str);
    $synset_str = trim($synset_str);
    $url_suffix = "";
    if (uservar('mode') == 'wordrandom') {
        $url_suffix = "&amp;mode=wordrandom";
    }
    $accesskey = "";
    $synmatches++;
    if ($synmatches < 10) {
        $accesskey = "accesskey=\"{$synmatches}\"";
    }
    ?>
	<li class="synsetlist"><a <?php 
    print $accesskey;
    ?>
 href="synset.php?id=<?php 
    print $db->f('meaning_id');
    print $url_suffix;
    ?>
    $query = sprintf("SELECT word FROM words WHERE id = %d", $id);
    $db->query($query);
    $db->next_record();
    doLog(unescape($db->f('word')), uservar('meaning_id'), REMOVE_SYNONYM);
    $query = sprintf("DELETE FROM word_meanings\n\t\tWHERE\n\t\t\tword_id = %d AND\n\t\t\tmeaning_id = %d", $id, uservar('meaning_id'));
    $db->query($query);
}
if (uservar('do_remove') == 1) {
    $title = T_("Synset removed");
    include "include/top.php";
    ?>
	<p><?php 
    print sprintf(T_("The synset <span class='inp'>%s</span> has been deleted."), join(', ', getSynset(uservar('meaning_id'))));
    ?>
</p>

	<p><a href="./"><?php 
    print T_("Return to homepage");
    ?>
</a></p>

	<?php 
    include "include/bottom.php";
    page_close();
    return;
} else {
    // time() tries to force reload:
    $url = sprintf("synset.php?id=%d&changed=1&oldmode=%s&rand=%d", intval(uservar('meaning_id')), uservar('mode'), time());
    header("Location: " . $url);
}
page_close();
print _("Subject:");
?>
</strong></td>
	<td>
		<?php 
popdownlist();
?>
	</td>
</tr>
<tr>
	<td></td>
	<td><?php 
print "<input type=\"submit\" value=\"" . _("Modify") . "\" />";
?>
</td>
</tr>
</table>

</form>

<p><a href="synset.php?id=<?php 
print escape(uservar('mid'));
?>
"><?php 
print _("Back to synset");
?>
</a></p>

<?php 
include "../include/bottom.php";
page_close();
    return;
}
# need this so mysql_real_escape_string() in tool.php won't fail
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error());
$query = sprintf("SELECT password FROM auth_user WHERE username = '******'", myaddslashes(uservar('email')));
$db->query($query);
if ($db->nf() == 0) {
    print "Error: user not found";
    return;
}
$db->next_record();
$pwd = $db->f('password');
$to = uservar('email');
$from = "dontreply@" . DOMAIN;
$subject = T_("Password Reminder");
$message = "\n" . sprintf(T_("Password reminder for %s"), HOMEPAGE) . "\n\n" . _("Username: "******"\n" . _("Password: "******"{$pwd}\n";
$ret = mail($to, $subject, $message, "From: {$from}");
if (!$ret) {
    print "Error: could not send mail";
    return;
}
$title = T_("Sending Password Reminder");
include "include/top.php";
?>

<p><?php 
print T_("A password reminder will soon be sent to your email address.");
?>
</p>

<p><a href="./"><?php 
    print "<ul class=\"compact\">";
    $substr_matches = 0;
    if (sizeof($results) > 0) {
        $i = 0;
        $more_matches = 0;
        foreach ($results as $word) {
            if ($i >= $limit - 1) {
                $more_matches = 1;
                break;
            }
            $i++;
            $w = uservar('word');
            if (strtolower($w) == strtolower($word)) {
                continue;
            }
            $w_regex = preg_quote(uservar('word'), '/');
            $w = preg_replace("/({$w_regex})/i", "<strong>\$1</strong>", $word);
            $substr_matches++;
            ?>
			<li><a href="<?php 
            print DEFAULT_SEARCH;
            ?>
?word=<?php 
            print urlencode($word);
            ?>
"><?php 
            print $w;
            ?>
</a></li>
			<?php 
        }
$query = sprintf("SELECT words.id AS id, word_meanings.id AS wmid,
	word, meaning_id, word_meanings.use_id, uses.name
	FROM words, word_meanings LEFT JOIN uses ON (uses.id=word_meanings.use_id)
	WHERE 
		word_meanings.meaning_id = %d AND
		words.id = word_meanings.word_id
	ORDER BY meaning_id, word", $meaning_id);
$db->query($query);

include("include/top.php");
?>

<?php 
if( uservar('changed') == 1 ) { ?>
	<p class="okay"><?php print T_("Modification saved.") ?></p>
<?php } else if( uservar('changed') == 2 ) { ?>
	<p class="okay"><?php print T_("Synset successfully created.") ?></p>
<?php } ?>

<?php if( isset($auth) && array_key_exists('uname', $auth->auth) ) { ?>
	<a href="synset_detail.php?mid=<?php print $meaning_id ?>"><?php print T_("Details") ?></a>
<?php } ?>

<form action="do_save.php" method="post">
<input type="hidden" name="meaning_id" value="<?php print $meaning_id ?>" />

<table border="0" cellpadding="3" cellspacing="0">

<?php
$i = 0;
$color_ct = 0;
<?php

include "include/phplib/prepend.php3";
include "include/tool.php";
$title = T_("Password Reminder");
include "include/top.php";
?>

<p><?php 
print sprintf(T_("Send password to '%s'?"), escape(uservar('email')));
?>
</p>

<form action="do_remind.php" method="post">
<input type="hidden" name="email" value="<?php 
print escape(uservar('email'));
?>
" />
<?php 
print "<input type=\"submit\" value =\"" . T_("Send password") . "\" />";
?>
</form>

<?php 
include "include/bottom.php";
</tr>
</table>

<table cellpadding="0" cellspacing="0" width="100%" class="compact">
<tr>
	<td class="compact" width="35%" valign="top">
		<?php 
if ($queryterm != "") {
    include "../include/external_searches.php";
}
?>
	</td>
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td class="compact" width="65%" valign="top">
		<?php 
if (uservar('word') && $queryterm != "") {
    ?>
			<p class="compact"><strong>Aktionen:</strong></p>
			<ul class="compact">
				<li><a href="add.php?word=<?php 
    print urlencode($_GET['word']);
    ?>
"><?php 
    print sprintf(_("Add '%s' and synonyms to OpenThesaurus"), escape($_GET['word']));
    ?>
</a></li>
			</ul>
		<?php 
}
?>
	</td>