function openthesaurus_searchSynonyms($query) { $start = getmicrotime(); $items = array(); $query_str = sprintf("\n\t\tSELECT words.id AS word_id, word, meaning_id\n\t\tFROM words, word_meanings, meanings\n\t\tWHERE \n\t\t\tword = '%s' AND\n\t\t\twords.id = word_meanings.word_id AND\n\t\t\tword_meanings.meaning_id = meanings.id AND\n\t\t\tmeanings.hidden = 0\n\t\n\t\tUNION\n\n\t\tSELECT words.id AS word_id, word, meaning_id\n\t\tFROM words, word_meanings, meanings\n\t\tWHERE \n\t\t\tlookup = '%s' AND\n\t\t\twords.id = word_meanings.word_id AND\n\t\t\tword_meanings.meaning_id = meanings.id AND\n\t\t\tmeanings.hidden = 0\n\n\t\tORDER BY word", myaddslashes($query), myaddslashes($query), myaddslashes($query), myaddslashes($query)); $db = new DB_Thesaurus(); $db->query($query_str); $synmatches = 1; if ($db->nf() == 0) { $item['words'] = array(); $items[] = $item; } while ($db->next_record()) { $mid = $db->f('meaning_id'); $item['words'] = getSynsetWithUsage($db->f('meaning_id'), 1); $items[] = $item; } $_GET['search'] = 1; # otherwise logSearch ignores the search logSearch($db, $query, $db->nf(), 0, getEndTimer(), 1); XMLRPC_response(XMLRPC_prepare($items), KD_XMLRPC_USERAGENT); }
include "include/phplib/prepend.php3"; $cancel_login = 1; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Default_Auth")); require_once "include/tool.php"; if (!WORD_DETAIL_WITHOUT_AUTH && $auth->auth["uid"] == "nobody") { $auth->login_if(true); return; } if (uservar('do_save') == 1 && $auth->auth["uid"] == "nobody") { $auth->login_if(true); return; } $db = new DB_Thesaurus(); $query = sprintf("SELECT words.word, word_meanings.use_id, word_meanings.meaning_id\n\tFROM word_meanings, words\n\tWHERE \n\t\tword_meanings.id = %d AND\n\t\twords.id = word_meanings.word_id", myaddslashes(uservar('wmid'))); $db->query($query); if ($db->nf() == 0) { print "ID not found"; return; } $db->next_record(); $word = $db->f('word'); $word_use = $db->f('use_id'); if (isset($_POST['use_id'])) { $word_use = $_POST['use_id']; } $meaning_id = $db->f('meaning_id'); $error = ""; $disambiguate = ""; if (uservar('do_save') == 1) { if (uservar('use_id') == 1) { $new_id = "NULL";
$db->query($query); ?> <table> <tr> <td><strong>#</strong></td> <td><strong>Date</strong></td> <td><strong>Term</strong></td> <td align="right"><strong>Matches</strong></td> <td align="right"><strong>IP</strong></td> </tr> </tr> <?php while ($db->next_record()) { $query2 = sprintf("SELECT word, meaning_id\n\t\t\tFROM word_meanings, words, meanings\n\t\t\tWHERE \n\t\t\t\twords.word = '%s' AND\n\t\t\t\twords.id = word_meanings.word_id AND\n\t\t\t\tword_meanings.meaning_id = meanings.id AND\n\t\t\t\tmeanings.hidden = 0\n\t\t\t\tLIMIT 1", addslashes($db->f('term'))); $db2->query($query2); if ($db2->nf() > 0) { continue; } if ($i % 2 == 0) { $col = ' bgcolor="#eeeeee"'; } else { $col = ""; } ?> <tr<?php print $col; ?> > <td align="right"><?php print $i + 1; ?>
<?php if (!(getenv('REMOTE_ADDR') == getenv('SERVER_ADDR'))) { print "Access from your host is denied."; return; } include "../../include/phplib/prepend.php3"; $db = new DB_Thesaurus(); include "../../include/tool.php"; $query = sprintf("SELECT DISTINCT word\n\tFROM words, word_meanings, meanings WHERE\n\t\twords.id = word_meanings.word_id AND\n\t\tword_meanings.meaning_id = meanings.id AND\n\t\thidden = 0\n\t\tORDER BY word"); $db->query($query); print $db->nf() . " words:<br />\n"; $word_ct = 0; while ($db->next_record()) { print $db->f('word') . " "; $word_ct++; if ($word_ct % 50 == 0) { print "\n\n<p>"; } } print "<hr />\n"; page_close();
include "include/phplib/prepend.php3"; $db = new DB_Thesaurus(); include "include/tool.php"; if (!emailOkay(uservar('email'))) { print sprintf(T_("Invalid email address '%s'."), escape(uservar('email'))); return; } if (!uservar('lgpl') == "1") { print T_("Error: the checkbox must be selected"); 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 user_id FROM auth_user WHERE username = '******'", myaddslashes(uservar('email'))); $db->query($query); if ($db->nf() == 1) { // username exists already header("Location: remind.php?email=" . urlencode(uservar('email'))); return; } $username = uservar('email'); $pwd = generatePassword(5); $to = uservar('email'); $from = "dontreply@" . DOMAIN; $subject = T_("Registered on ") . DOMAIN; $message = "\n" . _("You have succesfully registered on ") . HOMEPAGE . "\n" . _("Username: "******"{$username}\n" . _("Password: "******"{$pwd}\n"; $ret = mail($to, $subject, $message, "From: {$from}"); if (!$ret) { print "Error: could not send mail"; return; }
print "<p>All (non-hidden) synsets with at least {$limit} words (query_limit={$query_limit}).</p>"; $query = sprintf("SELECT meaning_id\n\tFROM word_meanings, meanings\n\tWHERE word_meanings.meaning_id = meanings.id AND\n\t\tmeanings.hidden = 0\n\tORDER by meaning_id LIMIT {$query_limit}"); $db->query($query); $i = 0; $ids = array(); while ($db->next_record()) { $ids[$db->f('meaning_id')] = 1; # 1 is a fake value } $i = 0; $c = 0; while (list($id, $val) = each($ids)) { $query = sprintf("SELECT id\n\t\tFROM word_meanings\n\t\tWHERE word_meanings.meaning_id = %d", $id); #print $query."<br>"; $db->query($query); if ($db->nf() >= $limit) { #if( $db->nf() == 1 ) { $c++; ?> <?php print $c; ?> . <a href="../synset.php?id=<?php print $id; ?> "><?php print join(', ', getSynset($id)); ?> </a><br /> <?php
function swissSpelling($word) { global $swiss_spelling; if ($swiss_spelling == 1) { # Seems we need to use conv because *this* file (ooo_new_export.php) # is in UTF-8? $word = preg_replace("/" . iconv("latin1", "utf8", "ß") . "/", "ss", $word); } return $word; } $title = "OpenThesaurus admin interface: Build OOo 2.0 thesaurus files"; include "../../include/top.php"; print strftime("%H:%M:%S") . " -- Building data...<br />\n"; $query = sprintf("SELECT words.id AS word_id, word, lookup, meaning_id, super_id, word_meanings.id AS wmid\n\tFROM words, word_meanings, meanings\n\tWHERE \n\t\twords.id = word_meanings.word_id AND\n\t\tword_meanings.meaning_id = meanings.id AND\n\t\tmeanings.hidden = 0\n\tORDER BY COALESCE(lookup, word)\n\t"); $db->query($query); print strftime("%H:%M:%S") . " -- Step 1 done, " . $db->nf() . " matches<br>"; flush(); $fh = fopen($output_file, 'w'); if (!$fh) { print "Error: Cannot open '{$output_file}' for writing.\n"; return; } $encoding = "ISO8859-1"; fwrite($fh, "{$encoding}\n"); $occurences = array(); while ($db->next_record()) { $w = $db->f('lookup'); $w = strtolower($w); if (!$w) { $w = $db->f('word'); $w = strtolower($w);
include "../include/phplib/prepend.php3"; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth")); $db = new DB_Thesaurus(); include "../include/tool.php"; if ($auth->auth['uname'] != 'admin') { print "Access denied."; return; } $title = "OpenThesaurus admin interface: average synset size"; include "../include/top.php"; $i = 1; $query = "SELECT id FROM meanings\n\tWHERE hidden = 0"; $db->query($query); $i = 0; $count = 0; while ($db->next_record()) { if ($i % 1000 == 0) { print "{$i}...<br>\n"; flush(); } $synset = getSynset($db->f('id')); $count = $count + sizeof($synset); $i++; } print "<p>"; print "Synsets: " . $db->nf() . "<br>"; print "Words in synsets: " . $count . "<br>"; print "Words/synset: " . $count / $db->nf() . "<br>"; include "../include/bottom.php"; page_close();
} } if ($remove == "ask") { $url = sprintf("get_comment.php?mode=%s&meaning_id=%d", urlencode(uservar('mode')), urlencode(uservar('meaning_id'))); if (uservar('mode') == 'random') { $url .= "&mode=random"; } header("Location: {$url}"); return; } else { if ($remove == "do") { # Don't allow the deletion of meanings that have a subordinate # or superordinate meaning: $query = sprintf("SELECT id FROM meanings WHERE\n\t\t(id = %d AND super_id IS NOT NULL) OR super_id = %d", uservar('meaning_id'), uservar('meaning_id')); $db->query($query); if ($db->nf() > 0) { print T_("This synset cannot be deleted because it is a subordinate or superordinate synset for another synset."); return; } ### Logging: doLog("", uservar('meaning_id'), REMOVE_SYNSET, uservar('comment')); ### Remove (=hide) the synset: $query = sprintf("UPDATE meanings\n\t\tSET hidden = 1\n\t\tWHERE id = %d", uservar('meaning_id')); $db->query($query); } else { if (trim(uservar('synonym_new'))) { ### Adding the new word: $query = sprintf("SELECT id, word FROM words WHERE word = '%s'", myaddslashes(escape(trim(uservar('synonym_new'))))); $db->query($query); $word_id = 0; $exists = 0;
</td> <td valign="top"> <?php $query = sprintf("SELECT username, perms, subs_date\n\t\t\tFROM auth_user\n\t\t\tORDER by subs_date DESC"); $db->query($query); ?> <?php $limit = 5; ?> <strong><?php print $limit; ?> most recently subscribed users of <?php print $db->nf(); ?> (<a href="users.php">show all</a>):</strong> <?php include "../include/admin/users_include.php"; ?> <?php $limit = 15; if (array_key_exists('searches_limit', $_GET) && $_GET['searches_limit']) { $limit = intval($_GET['searches_limit']); } $query = sprintf("SELECT count(*) AS number FROM search_log\n\t\t\tWHERE date >= DATE_SUB(NOW(), INTERVAL 1 DAY)"); $db->query($query); $db->next_record(); $all_searches_recent = $db->f('number');
print "Access denied."; return; } $title = "OpenThesaurus admin interface: count modified/unmodified synsets"; include "../include/top.php"; $i = 1; $query = "SELECT id FROM meanings\n\tWHERE hidden = 0"; $db->query($query); $i = 0; $unmodified = 0; $modified = 0; while ($db->next_record()) { if ($i % 1000 == 0) { print "{$i}...<br>\n"; flush(); } $query = sprintf("SELECT id\n\t\tFROM user_actions_log\n\t\tWHERE synset_id = %d", $db->f('id')); $db2->query($query); if ($db2->nf() == 0) { $unmodified++; } else { $modified++; } $i++; } print "<p>"; print "Synsets: " . $db->nf() . "<br>"; print "Unmodified synsets: " . $unmodified . "<br>"; print "Modified synsets: " . $modified . "<br>"; include "../include/bottom.php"; page_close();
words.id = word_meanings.word_id AND word_meanings.meaning_id = meanings.id AND meanings.hidden = 0 ORDER BY word", myaddslashes(trim(escape($_GET['word']))), myaddslashes(trim(escape($_GET['word'])))); $db->query($query); #print $query; $db->next_record(); if( uservar('substring') == 'on' ) { # TODO: no need to execute the query prior to this code $loc = sprintf("substring_search.php?word=%s&search=1", urlencode($_GET['word'])); header("Location: $loc"); return; } else if( $db->nf() == 0 ) { // no match: $loc = sprintf("suggestions.php?word=%s&search=1", urlencode($_GET['word'])); if( uservar('substring') ) { $loc .= "&substring=1"; } header("Location: $loc"); return; } elseif( $db->nf() > 1 ) { // more than one match: $loc = sprintf("multimatch.php?word=%s", urlencode(trim($_GET['word']))); if( array_key_exists('search', $_GET) ) { $loc .= sprintf("&search=%d", $_GET['search']); } header("Location: $loc");
<?php include "../../include/phplib/prepend.php3"; page_open(array("sess" => "Thesaurus_Session", "auth" => "Thesaurus_Auth")); $db = new DB_Thesaurus(); $db_tmp = new DB_Thesaurus(); include "../../include/tool.php"; if ($auth->auth['uname'] != 'admin') { print "Access denied."; return; } $title = "OpenThesaurus admin interface: Loose synsets"; include "../../include/top.php"; print "<p>Searching synsets which have a superordinate synset but\nwhich are not below the top synset...</p>"; $query = sprintf("SELECT id FROM meanings WHERE hidden = 0"); $db->query($query); $i = 1; print "Checking " . $db->nf() . " meanings:<br />\n"; while ($db->next_record()) { $synsets = getSuperordinateSynsets($db_tmp, $db->f('id')); if (sizeof($synsets) > 0) { $top_id = $synsets[sizeof($synsets) - 1]; if (sizeof($synsets) > 0 && $top_id != TOP_SYNSET_ID) { print "{$i}. <a href=\"../synset.php?id=" . $db->f('id') . "\">" . join(', ', getSynset($db->f('id'), 3)) . "</a> is a " . "<a href=\"../synset.php?id=" . $top_id . "\">" . join(', ', getSynset($top_id, 3)) . "</a><br />\n"; $i++; } } } print "<hr />\n"; page_close();