function get_similar_terms($lang_id, $compared_term, $max_count, $min_ranking) { // For a language $lang_id and a term $compared_term (UTF-8), // return an array with $max_count wordids with a similarity ranking // > $min_ranking, sorted decending. // If string is already in database, it will be excluded in results. global $tbpref; $compared_term_lc = mb_strtolower($compared_term, 'UTF-8'); $sql = "select WoID, WoTextLC from " . $tbpref . "words where WoLgID = " . $lang_id . " AND WoTextLC <> " . convert_string_to_sqlsyntax($compared_term_lc); $res = do_mysql_query($sql); $termlsd = array(); while ($record = mysql_fetch_assoc($res)) { $termlsd[$record["WoID"]] = getSimilarityRanking($compared_term_lc, $record["WoTextLC"]); } mysql_free_result($res); arsort($termlsd, SORT_NUMERIC); $r = array(); $i = 0; foreach ($termlsd as $key => $val) { if ($i >= $max_count) { break; } if ($val < $min_ranking) { break; } $i++; $r[$i] = $key; } return $r; }
function savetag($item, $key, $wid) { global $tbpref; if (!in_array($item, $_SESSION['TAGS'])) { runsql('insert into ' . $tbpref . 'tags (TgText) values(' . convert_string_to_sqlsyntax($item) . ')', ""); get_tags($refresh = 1); } runsql('insert ignore into ' . $tbpref . 'wordtags (WtWoID, WtTgID) select ' . $wid . ', TgID from ' . $tbpref . 'tags where TgText = ' . convert_string_to_sqlsyntax($item), ""); }
Setting all unknown words to Well Known (99) ***************************************************************/ require_once 'settings.inc.php'; require_once 'connect.inc.php'; require_once 'dbutils.inc.php'; require_once 'utilities.inc.php'; $langid = get_first_value("select TxLgID as value from " . $tbpref . "texts where TxID = " . $_REQUEST['text']); pagestart("Setting all blue words to Well-known", false); $sql = 'select distinct TiText, TiTextLC from (' . $tbpref . 'textitems left join ' . $tbpref . 'words on (TiTextLC = WoTextLC) and (TiLgID = WoLgID)) where TiIsNotWord = 0 and WoID is null and TiWordCount = 1 and TiTxID = ' . $_REQUEST['text'] . ' order by TiOrder'; $res = do_mysql_query($sql); $count = 0; $javascript = "var title='';"; while ($record = mysql_fetch_assoc($res)) { $term = $record['TiText']; $termlc = $record['TiTextLC']; $count1 = 0 + runsql('insert into ' . $tbpref . 'words (WoLgID, WoText, WoTextLC, WoStatus, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $langid . ', ' . convert_string_to_sqlsyntax($term) . ', ' . convert_string_to_sqlsyntax($termlc) . ', 99 , NOW(), ' . make_score_random_insert_update('id') . ')', ''); $wid = get_last_key(); if ($count1 > 0) { $javascript .= "title = make_tooltip(" . prepare_textdata_js($term) . ",'*','','99');"; } $javascript .= "\$('.TERM" . strToClassName($termlc) . "', context).removeClass('status0').addClass('status99 word" . $wid . "').attr('data_status','99').attr('data_wid','" . $wid . "').attr('title',title);"; $count += $count1; } mysql_free_result($res); echo "<p>OK, you know all " . $count . " word(s) well!</p>"; ?> <script type="text/javascript"> //<![CDATA[ var context = window.parent.frames['l'].document; var contexth = window.parent.frames['h'].document; <?php
} else { $translation = $translation_raw; } // INSERT if ($_REQUEST['op'] == 'Save') { $message = runsql('insert into ' . $tbpref . 'words (WoLgID, WoTextLC, WoText, ' . 'WoStatus, WoTranslation, WoSentence, WoRomanization, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $_REQUEST["WoLgID"] . ', ' . convert_string_to_sqlsyntax(mb_strtolower($_REQUEST["WoText"], 'UTF-8')) . ', ' . convert_string_to_sqlsyntax($_REQUEST["WoText"]) . ', ' . $_REQUEST["WoStatus"] . ', ' . convert_string_to_sqlsyntax($translation) . ', ' . convert_string_to_sqlsyntax(repl_tab_nl($_REQUEST["WoSentence"])) . ', ' . convert_string_to_sqlsyntax($_REQUEST["WoRomanization"]) . ', NOW(), ' . make_score_random_insert_update('id') . ')', "Saved", $sqlerrdie = FALSE); $wid = get_last_key(); } else { $oldstatus = $_REQUEST["WoOldStatus"]; $newstatus = $_REQUEST["WoStatus"]; $xx = ''; if ($oldstatus != $newstatus) { $xx = ', WoStatus = ' . $newstatus . ', WoStatusChanged = NOW()'; } $wid = $_REQUEST["WoID"] + 0; $message = runsql('update ' . $tbpref . 'words set WoText = ' . convert_string_to_sqlsyntax($_REQUEST["WoText"]) . ', WoTextLC = ' . convert_string_to_sqlsyntax(mb_strtolower($_REQUEST["WoText"], 'UTF-8')) . ', WoTranslation = ' . convert_string_to_sqlsyntax($translation) . ', WoSentence = ' . convert_string_to_sqlsyntax(repl_tab_nl($_REQUEST["WoSentence"])) . ', WoRomanization = ' . convert_string_to_sqlsyntax($_REQUEST["WoRomanization"]) . $xx . ',' . make_score_random_insert_update('u') . ' where WoID = ' . $_REQUEST["WoID"], "Updated", $sqlerrdie = FALSE); } saveWordTags($wid); } // NEW if (isset($_REQUEST['new']) && isset($_REQUEST['lang'])) { $scrdir = getScriptDirectionTag($_REQUEST['lang']); ?> <h4>New Term</h4> <script type="text/javascript" src="js/unloadformcheck.js" charset="utf-8"></script> <form name="newword" class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <input type="hidden" name="WoLgID" id="langfield" value="<?php
if (isset($_REQUEST['op'])) { $textlc = trim(prepare_textdata($_REQUEST["WoTextLC"])); $text = trim(prepare_textdata($_REQUEST["WoText"])); if (mb_strtolower($text, 'UTF-8') == $textlc) { // UPDATE if ($_REQUEST['op'] == 'Change') { $titeltext = "Edit Term: " . tohtml(prepare_textdata($_REQUEST["WoTextLC"])); pagestart_nobody($titeltext); echo '<h4><span class="bigger">' . $titeltext . '</span></h4>'; $oldstatus = $_REQUEST["WoOldStatus"]; $newstatus = $_REQUEST["WoStatus"]; $xx = ''; if ($oldstatus != $newstatus) { $xx = ', WoStatus = ' . $newstatus . ', WoStatusChanged = NOW()'; } $message = runsql('update words set WoText = ' . convert_string_to_sqlsyntax($_REQUEST["WoText"]) . ', WoTranslation = ' . convert_string_to_sqlsyntax($translation) . ', WoSentence = ' . convert_string_to_sqlsyntax(repl_tab_nl($_REQUEST["WoSentence"])) . ', WoRomanization = ' . convert_string_to_sqlsyntax($_REQUEST["WoRomanization"]) . $xx . ',' . make_score_random_insert_update('u') . ' where WoID = ' . $_REQUEST["WoID"], "Updated"); $wid = $_REQUEST["WoID"]; saveWordTags($wid); } // $_REQUEST['op'] == 'Change' } else { // (mb_strtolower($text, 'UTF-8') != $textlc) $titeltext = "New/Edit Term: " . tohtml(prepare_textdata($_REQUEST["WoTextLC"])); pagestart_nobody($titeltext); echo '<h4><span class="bigger">' . $titeltext . '</span></h4>'; $message = 'Error: Term in lowercase must be exactly = "' . $textlc . '", please go back and correct this!'; echo error_message_with_hide($message, 0); pageend(); exit; } ?>
} } elseif (substr($_REQUEST['op'], 0, 5) == 'Creat') { $langid = $_REQUEST["LgID"] + 0; $title = stripTheSlashesIfNeeded($_REQUEST["TxTitle"]); $source_uri = stripTheSlashesIfNeeded($_REQUEST["TxSourceURI"]); $_REQUEST["TextTags"] = json_decode(stripTheSlashesIfNeeded($_REQUEST["TextTags"]), true); $textcount = $_REQUEST["TextCount"] + 0; $texts = $_REQUEST["text"]; if (count($texts) != $textcount) { $message = "Error: Number of texts wrong: " . count($texts) . " != " . $textcount; } else { $imported = 0; for ($i = 0; $i < $textcount; $i++) { $counter = makeCounterWithTotal($textcount, $i + 1); $thistitle = $title . ($counter == '' ? '' : ' (' . $counter . ')'); $imported = $imported + runsql('insert into ' . $tbpref . 'texts (TxLgID, TxTitle, TxText, TxAnnotatedText, TxAudioURI, TxSourceURI) values( ' . $langid . ', ' . convert_string_to_sqlsyntax($thistitle) . ', ' . convert_string_to_sqlsyntax($texts[$i]) . ", '', NULL, " . convert_string_to_sqlsyntax($source_uri) . ')', ''); $id = get_last_key(); saveTextTags($id); splitCheckText($texts[$i], $langid, $id); } } $message = $imported . " Text(s) imported!"; echo error_message_with_hide($message, 0); ?> <p> <br /><input type="button" value="Show Texts" onclick="location.href='edit_texts.php';" /></p> <?php } } else { ?>
require_once 'settings.inc.php'; require_once 'connect.inc.php'; require_once 'dbutils.inc.php'; require_once 'utilities.inc.php'; $value = isset($_POST['value']) ? $_POST['value'] : ""; $value = trim($value); $id = isset($_POST['id']) ? $_POST['id'] : ""; if (substr($id, 0, 5) == "trans") { $id = substr($id, 5); if ($value == '') { $value = '*'; } $message = runsql('update ' . $tbpref . 'words set WoTranslation = ' . convert_string_to_sqlsyntax(repl_tab_nl($value)) . ' where WoID = ' . $id, ""); echo get_first_value("select WoTranslation as value from " . $tbpref . "words where WoID = " . $id); exit; } if (substr($id, 0, 5) == "roman") { if ($value == '*') { $value = ''; } $id = substr($id, 5); $message = runsql('update ' . $tbpref . 'words set WoRomanization = ' . convert_string_to_sqlsyntax(repl_tab_nl($value)) . ' where WoID = ' . $id, ""); $value = get_first_value("select WoRomanization as value from " . $tbpref . "words where WoID = " . $id); if ($value == '') { echo '*'; } else { echo $value; } exit; } echo "ERROR - please refresh page!";
unless such conditions are required by law. Developed by J. Pierre in 2011. ***************************************************************/ /************************************************************** Call: insert_word_wellknown.php?tid=[textid]&ord=[textpos] Ignore single word (new term with status 99) ***************************************************************/ include "connect.inc.php"; include "settings.inc.php"; include "utilities.inc.php"; $word = get_first_value("select TiText as value from textitems where TiWordCount = 1 and TiTxID = " . $_REQUEST['tid'] . " and TiOrder = " . $_REQUEST['ord']); $wordlc = mb_strtolower($word, 'UTF-8'); $langid = get_first_value("select TxLgID as value from texts where TxID = " . $_REQUEST['tid']); pagestart("Term: " . $word, false); $m1 = runsql('insert into words (WoLgID, WoText, WoTextLC, WoStatus, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $langid . ', ' . convert_string_to_sqlsyntax($word) . ', ' . convert_string_to_sqlsyntax($wordlc) . ', 99, NOW(), ' . make_score_random_insert_update('id') . ')', 'Term added'); $wid = get_last_key(); echo "<p>OK, you know this term well!</p>"; $hex = strToClassName($wordlc); ?> <script type="text/javascript"> //<![CDATA[ var context = window.parent.frames['l'].document; var contexth = window.parent.frames['h'].document; var title = make_tooltip(<?php echo prepare_textdata_js($word); ?> ,'*','','99'); $('.TERM<?php echo $hex; ?>
function savetag($item, $key, $wid) { global $tbpref; runsql('insert into ' . $tbpref . 'tags (TgText) values(' . convert_string_to_sqlsyntax($item) . ')', ""); runsql('insert into ' . $tbpref . 'wordtags (WtWoID, WtTgID) select ' . $wid . ', TgID from ' . $tbpref . 'tags where TgText = ' . convert_string_to_sqlsyntax($item), ""); }
$editmode = getreq('edit') + 0; $delmode = getreq('del') + 0; $ann = get_first_value("select TxAnnotatedText as value from " . $tbpref . "texts where TxID = " . $textid); $ann_exists = strlen($ann) > 0; if ($ann_exists) { $ann = recreate_save_ann($textid, $ann); $ann_exists = strlen($ann) > 0; } if ($textid == 0) { header("Location: edit_texts.php"); exit; } if ($delmode) { // Delete if ($ann_exists) { $dummy = runsql('update ' . $tbpref . 'texts set ' . 'TxAnnotatedText = ' . convert_string_to_sqlsyntax("") . ' where TxID = ' . $textid, ""); } $ann_exists = get_first_value("select length(TxAnnotatedText) as value from " . $tbpref . "texts where TxID = " . $textid) + 0 > 0; if (!$ann_exists) { header("Location: print_text.php?text=" . $textid); exit; } } $sql = 'select TxLgID, TxTitle, TxAudioURI, TxSourceURI from ' . $tbpref . 'texts where TxID = ' . $textid; $res = do_mysql_query($sql); $record = mysql_fetch_assoc($res); $title = $record['TxTitle']; $sourceURI = $record['TxSourceURI']; $langid = $record['TxLgID']; $audio = $record['TxAudioURI']; if (!isset($audio)) {
} else { // CHECK if ($_REQUEST['op'] == 'Check') { echo '<p><input type="button" value="<< Back" onclick="history.back();" /></p>'; echo splitCheckText($_REQUEST['TxText'], $_REQUEST['TxLgID'], -1); echo '<p><input type="button" value="<< Back" onclick="history.back();" /></p>'; pageend(); exit; } elseif (substr($_REQUEST['op'], 0, 4) == 'Save') { $message1 = runsql('insert into ' . $tbpref . 'texts (TxLgID, TxTitle, TxText, TxAnnotatedText, TxAudioURI, TxSourceURI) values( ' . $_REQUEST["TxLgID"] . ', ' . convert_string_to_sqlsyntax($_REQUEST["TxTitle"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["TxText"]) . ", '', " . convert_string_to_sqlsyntax($_REQUEST["TxAudioURI"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["TxSourceURI"]) . ')', "Saved"); $id = get_last_key(); saveTextTags($id); } elseif (substr($_REQUEST['op'], 0, 6) == 'Change') { $oldtext = get_first_value('select TxText as value from ' . $tbpref . 'texts where TxID = ' . $_REQUEST["TxID"]); $textsdiffer = convert_string_to_sqlsyntax($_REQUEST["TxText"]) != convert_string_to_sqlsyntax($oldtext); $message1 = runsql('update ' . $tbpref . 'texts set ' . 'TxLgID = ' . $_REQUEST["TxLgID"] . ', ' . 'TxTitle = ' . convert_string_to_sqlsyntax($_REQUEST["TxTitle"]) . ', ' . 'TxText = ' . convert_string_to_sqlsyntax($_REQUEST["TxText"]) . ', ' . 'TxAudioURI = ' . convert_string_to_sqlsyntax($_REQUEST["TxAudioURI"]) . ', ' . 'TxSourceURI = ' . convert_string_to_sqlsyntax($_REQUEST["TxSourceURI"]) . ' ' . 'where TxID = ' . $_REQUEST["TxID"], "Updated"); $id = $_REQUEST["TxID"]; saveTextTags($id); } $message2 = runsql('delete from ' . $tbpref . 'sentences where SeTxID = ' . $id, "Sentences deleted"); $message3 = runsql('delete from ' . $tbpref . 'textitems where TiTxID = ' . $id, "Textitems deleted"); adjust_autoincr('sentences', 'SeID'); adjust_autoincr('textitems', 'TiID'); splitCheckText(get_first_value('select TxText as value from ' . $tbpref . 'texts where TxID = ' . $id), $_REQUEST["TxLgID"], $id); $message = $message1 . " / " . $message2 . " / " . $message3 . " / Sentences added: " . get_first_value('select count(*) as value from ' . $tbpref . 'sentences where SeTxID = ' . $id) . " / Text items added: " . get_first_value('select count(*) as value from ' . $tbpref . 'textitems where TiTxID = ' . $id); if (substr($_REQUEST['op'], -8) == "and Open") { header('Location: do_text.php?start=' . $id); exit; } } }
// if (! isset($_REQUEST['op'])) // edit_word.php?tid=..&ord=..&wid=.. $wid = getreq('wid'); if ($wid == '') { $sql = 'select TiText, TiLgID from ' . $tbpref . 'textitems where TiTxID = ' . $_REQUEST['tid'] . ' and TiWordCount = 1 and TiOrder = ' . $_REQUEST['ord']; $res = do_mysql_query($sql); $record = mysql_fetch_assoc($res); if ($record) { $term = $record['TiText']; $lang = $record['TiLgID']; } else { my_die("Cannot access Term and Language in edit_word.php"); } mysql_free_result($res); $termlc = mb_strtolower($term, 'UTF-8'); $wid = get_first_value("select WoID as value from " . $tbpref . "words where WoLgID = " . $lang . " and WoTextLC = " . convert_string_to_sqlsyntax($termlc)); } else { $sql = 'select WoText, WoLgID from ' . $tbpref . 'words where WoID = ' . $wid; $res = do_mysql_query($sql); $record = mysql_fetch_assoc($res); if ($record) { $term = $record['WoText']; $lang = $record['WoLgID']; } else { my_die("Cannot access Term and Language in edit_word.php"); } mysql_free_result($res); $termlc = mb_strtolower($term, 'UTF-8'); } $new = isset($wid) == FALSE; $titletext = ($new ? "New Term" : "Edit Term") . ": " . tohtml($term);
function refreshText($word, $tid) { global $tbpref; // $word : only sentences with $word // $tid : textid // only to be used when $showAll = 0 ! $out = ''; $wordlc = trim(mb_strtolower($word, 'UTF-8')); if ($wordlc == '') { return ''; } $sql = 'SELECT distinct TiSeID FROM ' . $tbpref . 'textitems WHERE TiIsNotWord = 0 and TiTextLC = ' . convert_string_to_sqlsyntax($wordlc) . ' and TiTxID = ' . $tid . ' order by TiSeID'; $res = do_mysql_query($sql); $inlist = '('; while ($record = mysql_fetch_assoc($res)) { if ($inlist == '(') { $inlist .= $record['TiSeID']; } else { $inlist .= ',' . $record['TiSeID']; } } mysql_free_result($res); if ($inlist == '(') { return ''; } else { $inlist = ' where TiSeID in ' . $inlist . ') '; } $sql = 'select TiWordCount as Code, TiOrder, TiIsNotWord, WoID from (' . $tbpref . 'textitems left join ' . $tbpref . 'words on (TiTextLC = WoTextLC) and (TiLgID = WoLgID)) ' . $inlist . ' order by TiOrder asc, TiWordCount desc'; $res = do_mysql_query($sql); $hideuntil = -1; $hidetag = "removeClass('hide');"; while ($record = mysql_fetch_assoc($res)) { // MAIN LOOP $actcode = $record['Code'] + 0; $order = $record['TiOrder'] + 0; $notword = $record['TiIsNotWord'] + 0; $termex = isset($record['WoID']); $spanid = 'ID-' . $order . '-' . $actcode; if ($hideuntil > 0) { if ($order <= $hideuntil) { $hidetag = "addClass('hide');"; } else { $hideuntil = -1; $hidetag = "removeClass('hide');"; } } if ($notword != 0) { // NOT A TERM $out .= "\$('#" . $spanid . "',context)." . $hidetag . "\n"; } else { // A TERM if ($actcode > 1) { // A MULTIWORD FOUND if ($termex) { // MULTIWORD FOUND - DISPLAY if ($hideuntil == -1) { $hideuntil = $order + ($actcode - 1) * 2; } $out .= "\$('#" . $spanid . "',context)." . $hidetag . "\n"; } else { // MULTIWORD PLACEHOLDER - NO DISPLAY $out .= "\$('#" . $spanid . "',context).addClass('hide');\n"; } } else { // ($actcode == 1) -- A WORD FOUND $out .= "\$('#" . $spanid . "',context)." . $hidetag . "\n"; } } } // MAIN LOOP mysql_free_result($res); return $out; }
if (isset($_REQUEST['del'])) { $anztexts = get_first_value('select count(TxID) as value from texts where TxLgID = ' . $_REQUEST['del']); $anzarchtexts = get_first_value('select count(AtID) as value from archivedtexts where AtLgID = ' . $_REQUEST['del']); $anzwords = get_first_value('select count(WoID) as value from words where WoLgID = ' . $_REQUEST['del']); if ($anztexts > 0 || $anzarchtexts > 0 || $anzwords > 0) { $message = 'You must first delete texts, archived texts and words with this language!'; } else { $message = runsql('delete from languages where LgID = ' . $_REQUEST['del'], "Deleted"); adjust_autoincr('languages', 'LgID'); } } elseif (isset($_REQUEST['op'])) { // INSERT if ($_REQUEST['op'] == 'Save') { $message = runsql('insert into languages (LgName, LgDict1URI, LgDict2URI, LgGoogleTranslateURI, LgTextSize, LgCharacterSubstitutions, LgRegexpSplitSentences, LgExceptionsSplitSentences, LgRegexpWordCharacters, LgRemoveSpaces, LgSplitEachChar, LgRightToLeft) values(' . convert_string_to_sqlsyntax($_REQUEST["LgName"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["LgDict1URI"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["LgDict2URI"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["LgGoogleTranslateURI"]) . ', ' . $_REQUEST["LgTextSize"] . ', ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgCharacterSubstitutions"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpSplitSentences"]) . ', ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgExceptionsSplitSentences"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpWordCharacters"]) . ', ' . $_REQUEST["LgRemoveSpaces"] . ', ' . $_REQUEST["LgSplitEachChar"] . ', ' . $_REQUEST["LgRightToLeft"] . ')', 'Saved'); } elseif ($_REQUEST['op'] == 'Change') { $message = runsql('update languages set ' . 'LgName = ' . convert_string_to_sqlsyntax($_REQUEST["LgName"]) . ', ' . 'LgDict1URI = ' . convert_string_to_sqlsyntax($_REQUEST["LgDict1URI"]) . ', ' . 'LgDict2URI = ' . convert_string_to_sqlsyntax($_REQUEST["LgDict2URI"]) . ', ' . 'LgGoogleTranslateURI = ' . convert_string_to_sqlsyntax($_REQUEST["LgGoogleTranslateURI"]) . ', ' . 'LgTextSize = ' . $_REQUEST["LgTextSize"] . ', ' . 'LgCharacterSubstitutions = ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgCharacterSubstitutions"]) . ', ' . 'LgRegexpSplitSentences = ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpSplitSentences"]) . ', ' . 'LgExceptionsSplitSentences = ' . convert_string_to_sqlsyntax_notrim_nonull($_REQUEST["LgExceptionsSplitSentences"]) . ', ' . 'LgRegexpWordCharacters = ' . convert_string_to_sqlsyntax($_REQUEST["LgRegexpWordCharacters"]) . ', ' . 'LgRemoveSpaces = ' . $_REQUEST["LgRemoveSpaces"] . ', ' . 'LgSplitEachChar = ' . $_REQUEST["LgSplitEachChar"] . ', ' . 'LgRightToLeft = ' . $_REQUEST["LgRightToLeft"] . ' where LgID = ' . $_REQUEST["LgID"], 'Updated'); } } // NEW if (isset($_REQUEST['new'])) { ?> <h4>New Language <a target="_blank" href="info.htm#howtolang"><img src="icn/question-frame.png" title="Help" alt="Help" /></a> </h4> <form class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <table class="tab3" cellspacing="0" cellpadding="5"> <tr> <td class="td1 right">Language:</td> <td class="td1"><input type="text" class="notempty setfocus" name="LgName" value="" maxlength="40" size="40" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
$allaction = $_REQUEST['allaction']; if ($allaction == 'delall') { $message = runsql('delete from ' . $tbpref . 'tags where (1=1) ' . $wh_query, "Deleted"); runsql("DELETE " . $tbpref . "wordtags FROM (" . $tbpref . "wordtags LEFT JOIN " . $tbpref . "tags on WtTgID = TgID) WHERE TgID IS NULL", ''); adjust_autoincr('tags', 'TgID'); } } elseif (isset($_REQUEST['del'])) { $message = runsql('delete from ' . $tbpref . 'tags where TgID = ' . $_REQUEST['del'], "Deleted"); runsql("DELETE " . $tbpref . "wordtags FROM (" . $tbpref . "wordtags LEFT JOIN " . $tbpref . "tags on WtTgID = TgID) WHERE TgID IS NULL", ''); adjust_autoincr('tags', 'TgID'); } elseif (isset($_REQUEST['op'])) { // INSERT if ($_REQUEST['op'] == 'Save') { $message = runsql('insert into ' . $tbpref . 'tags (TgText, TgComment) values(' . convert_string_to_sqlsyntax($_REQUEST["TgText"]) . ', ' . convert_string_to_sqlsyntax_nonull($_REQUEST["TgComment"]) . ')', "Saved", $sqlerrdie = FALSE); } elseif ($_REQUEST['op'] == 'Change') { $message = runsql('update ' . $tbpref . 'tags set TgText = ' . convert_string_to_sqlsyntax($_REQUEST["TgText"]) . ', TgComment = ' . convert_string_to_sqlsyntax_nonull($_REQUEST["TgComment"]) . ' where TgID = ' . $_REQUEST["TgID"], "Updated", $sqlerrdie = FALSE); } } // NEW if (isset($_REQUEST['new'])) { ?> <h4>New Tag</h4> <script type="text/javascript" src="js/unloadformcheck.js" charset="utf-8"></script> <form name="newtag" class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <table class="tab3" cellspacing="0" cellpadding="5"> <tr> <td class="td1 right">Tag:</td>
include "utilities.inc.php"; // INSERT if (isset($_REQUEST['op'])) { if ($_REQUEST['op'] == 'Save') { $text = trim(prepare_textdata($_REQUEST["WoText"])); $textlc = mb_strtolower($text, 'UTF-8'); $translation_raw = repl_tab_nl(getreq("WoTranslation")); if ($translation_raw == '') { $translation = '*'; } else { $translation = $translation_raw; } $titeltext = "New Term: " . tohtml($textlc); pagestart_nobody($titeltext); echo '<h4><span class="bigger">' . $titeltext . '</span></h4>'; $message = runsql('insert into words (WoLgID, WoTextLC, WoText, ' . 'WoStatus, WoTranslation, WoSentence, WoRomanization, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $_REQUEST["WoLgID"] . ', ' . convert_string_to_sqlsyntax($textlc) . ', ' . convert_string_to_sqlsyntax($text) . ', ' . $_REQUEST["WoStatus"] . ', ' . convert_string_to_sqlsyntax($translation) . ', ' . convert_string_to_sqlsyntax(repl_tab_nl($_REQUEST["WoSentence"])) . ', ' . convert_string_to_sqlsyntax($_REQUEST["WoRomanization"]) . ', NOW(), ' . make_score_random_insert_update('id') . ')', "Term saved"); if (substr($message, 0, 22) == 'Error: Duplicate entry') { $message = 'Error: Duplicate entry for ' . $textlc; } $wid = get_last_key(); $hex = strToClassName(prepare_textdata($textlc)); saveWordTags($wid); $showAll = getSetting('showallwords'); $showAll = $showAll == '' ? 1 : ((int) $showAll != 0 ? 1 : 0); ?> <p><?php echo tohtml($message); ?> </p>
// ********* WORDPRESS LOGOUT ********* ?> <br /><br /></li> <li><a href="info.htm">Help/Information</a></li> <li><a href="mobile.php">Mobile LWT (Experimental)</a></li> </ul> <p class="smallgray graydotted"> </p> <table><tr><td class="width50px"><a target="_blank" href="http://unlicense.org/"><img alt="Public Domain" title="Public Domain" src="img/public_domain.png" /></a></td><td><p class="smallgray"><a href="http://lwt.sourceforge.net/" target="_blank">"Learning with Texts" (LWT)</a> is free and unencumbered software released<br />into the <b>PUBLIC DOMAIN</b>. <a href="http://unlicense.org/" target="_blank">More information and detailed Unlicense ...</a><br /> <?php flush(); // optimizedb(); $p = convert_string_to_sqlsyntax_nonull($tbpref); $mb = get_first_value("SELECT round(sum(data_length+index_length)/1024/1024,1) as value FROM information_schema.TABLES where table_schema = " . convert_string_to_sqlsyntax($dbname) . " and table_name in (" . "CONCAT(" . $p . ",'archivedtexts')," . "CONCAT(" . $p . ",'archtexttags')," . "CONCAT(" . $p . ",'languages')," . "CONCAT(" . $p . ",'sentences')," . "CONCAT(" . $p . ",'settings')," . "CONCAT(" . $p . ",'tags')," . "CONCAT(" . $p . ",'tags2')," . "CONCAT(" . $p . ",'textitems')," . "CONCAT(" . $p . ",'texts')," . "CONCAT(" . $p . ",'texttags')," . "CONCAT(" . $p . ",'words')," . "CONCAT(" . $p . ",'wordtags'))"); if (!isset($mb)) { $mb = '0.0'; } ?> This is <b>LWT <?php echo get_version(); ?> </b><br />Database: <b><?php echo $dbname; ?> </b> on <b><?php echo $server; ?> </b> / <?php
$count = 0; } else { if ($nosent) { // No sent. mode 4+5 $num = 0; $notvalid = 1; } else { // $nosent == FALSE, mode 1-3 $pass = 0; $sentexcl = ''; while ($pass < 3) { $pass++; if ($debug) { echo "DEBUG search sent: pass: {$pass} <br />"; } $sql = 'SELECT DISTINCT SeID FROM sentences, textitems WHERE TiTextLC = ' . convert_string_to_sqlsyntax($wordlc) . $sentexcl . ' AND SeID = TiSeID AND SeLgID = ' . $lang . ' order by rand() limit 1'; $res = mysql_query($sql); if ($res == FALSE) { die("Invalid query: {$sql}"); } $record = mysql_fetch_assoc($res); if ($record) { // random sent found $num = 1; $seid = $record['SeID']; if (AreUnknownWordsInSentence($seid)) { if ($debug) { echo "DEBUG sent: {$seid} has unknown words<br />"; } $sentexcl = ' AND SeID != ' . $seid . ' '; $num = 0;
$allaction = $_REQUEST['allaction']; if ($allaction == 'delall') { $message = runsql('delete from tags where (1=1) ' . $wh_query, "Deleted"); runsql("DELETE wordtags FROM (wordtags LEFT JOIN tags on WtTgID = TgID) WHERE TgID IS NULL", ''); adjust_autoincr('tags', 'TgID'); } } elseif (isset($_REQUEST['del'])) { $message = runsql('delete from tags where TgID = ' . $_REQUEST['del'], "Deleted"); runsql("DELETE wordtags FROM (wordtags LEFT JOIN tags on WtTgID = TgID) WHERE TgID IS NULL", ''); adjust_autoincr('tags', 'TgID'); } elseif (isset($_REQUEST['op'])) { // INSERT if ($_REQUEST['op'] == 'Save') { $message = runsql('insert into tags (TgText, TgComment) values(' . convert_string_to_sqlsyntax($_REQUEST["TgText"]) . ', ' . convert_string_to_sqlsyntax_nonull($_REQUEST["TgComment"]) . ')', "Saved"); } elseif ($_REQUEST['op'] == 'Change') { $message = runsql('update tags set TgText = ' . convert_string_to_sqlsyntax($_REQUEST["TgText"]) . ', TgComment = ' . convert_string_to_sqlsyntax_nonull($_REQUEST["TgComment"]) . ' where TgID = ' . $_REQUEST["TgID"], "Updated"); } } // NEW if (isset($_REQUEST['new'])) { ?> <h4>New Tag</h4> <form name="newtag" class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <table class="tab3" cellspacing="0" cellpadding="5"> <tr> <td class="td1 right">Tag:</td> <td class="td1"><input class="notempty setfocus noblanksnocomma" type="text" name="TgText" data_info="Tag" value="" maxlength="20" size="20" /> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" /></td>
<li><a href="upload_words.php">Import Terms</a></li> <li><a href="backup_restore.php">Backup/Restore LWT Database</a> <br /><br /></li> <li><a href="settings.php">Settings/Preferences</a> <br /><br /></li> <li><a href="info.htm">Help/Information</a></li> <li><a href="mobile.php">Mobile LWT (Experimental)</a></li> </ul> <p class="smallgray graydotted"> </p> <table><tr><td class="width50px"><a target="_blank" href="http://en.wikipedia.org/wiki/Public_domain_software"><img alt="Public Domain" src="img/public_domain.png" /></a></td><td><p class="smallgray"><a href="http://lwt.sourceforge.net/" target="_blank">"Learning with Texts" (LWT)</a> is released into the Public Domain. This applies worldwide.<br />In case this is not legally possible, any entity is granted the right to use this work for any purpose,<br />without any conditions, unless such conditions are required by law.<br /> <?php flush(); optimizedb(); $mb = get_first_value("SELECT round(sum(data_length+index_length)/1024/1024,1) as value FROM information_schema.TABLES where table_schema = " . convert_string_to_sqlsyntax($dbname) . " GROUP BY table_schema"); ?> This is <b>LWT <?php echo get_version(); ?> </b> / Database: <b><?php echo $dbname; ?> </b> on <b><?php echo $server; ?> </b> / DB-Size: <b><?php echo $mb; ?> MB</b></p></td></tr></table>
$message = runsql('delete from archivedtexts where AtID = ' . $_REQUEST['del'], "Archived Texts deleted"); adjust_autoincr('archivedtexts', 'AtID'); runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", ''); } elseif (isset($_REQUEST['unarch'])) { $message2 = runsql('insert into texts (TxLgID, TxTitle, TxText, TxAudioURI) select AtLgID, AtTitle, AtText, AtAudioURI from archivedtexts where AtID = ' . $_REQUEST['unarch'], "Texts added"); $id = get_last_key(); runsql('insert into texttags (TtTxID, TtT2ID) select ' . $id . ', AgT2ID from archtexttags where AgAtID = ' . $_REQUEST['unarch'], ""); splitText(get_first_value('select TxText as value from texts where TxID = ' . $id), get_first_value('select TxLgID as value from texts where TxID = ' . $id), $id); $message1 = runsql('delete from archivedtexts where AtID = ' . $_REQUEST['unarch'], "Archived Texts deleted"); $message = $message1 . " / " . $message2 . " / Sentences added: " . get_first_value('select count(*) as value from sentences where SeTxID = ' . $id) . " / Text items added: " . get_first_value('select count(*) as value from textitems where TiTxID = ' . $id); adjust_autoincr('archivedtexts', 'AtID'); runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", ''); } elseif (isset($_REQUEST['op'])) { // UPDATE if ($_REQUEST['op'] == 'Change') { $message = runsql('update archivedtexts set ' . 'AtLgID = ' . $_REQUEST["AtLgID"] . ', ' . 'AtTitle = ' . convert_string_to_sqlsyntax($_REQUEST["AtTitle"]) . ', ' . 'AtText = ' . convert_string_to_sqlsyntax($_REQUEST["AtText"]) . ', ' . 'AtAudioURI = ' . convert_string_to_sqlsyntax($_REQUEST["AtAudioURI"]) . ' ' . 'where AtID = ' . $_REQUEST["AtID"], "Updated"); $id = $_REQUEST["AtID"]; } saveArchivedTextTags($id); } // CHG if (isset($_REQUEST['chg'])) { $sql = 'select AtLgID, AtTitle, AtText, AtAudioURI from archivedtexts where AtID = ' . $_REQUEST['chg']; $res = mysql_query($sql); if ($res == FALSE) { die("Invalid Query: {$sql}"); } if ($record = mysql_fetch_assoc($res)) { ?> <h4>Edit Archived Text</h4>
$data = trim(stripTheSlashesIfNeeded($_POST['data'])); // translation $text = trim(stripTheSlashesIfNeeded($_POST['text'])); // only wid=0 (new) $lang = $_POST['lang'] + 0; // only wid=0 (lang-id) // Save data $success = ""; if ($wid == 0) { $textlc = mb_strtolower($text, 'UTF-8'); $dummy = runsql('insert into ' . $tbpref . 'words (WoLgID, WoTextLC, WoText, ' . 'WoStatus, WoTranslation, WoSentence, WoRomanization, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values( ' . $lang . ', ' . convert_string_to_sqlsyntax($textlc) . ', ' . convert_string_to_sqlsyntax($text) . ', 1, ' . convert_string_to_sqlsyntax($data) . ', ' . convert_string_to_sqlsyntax('') . ', ' . convert_string_to_sqlsyntax('') . ', NOW(), ' . make_score_random_insert_update('id') . ')', ""); if ($dummy == 1) { $success = $textlc; } } else { if (get_first_value("select count(WoID) as value from " . $tbpref . "words where WoID = " . $wid) == 1) { $oldtrans = get_first_value("select WoTranslation as value from " . $tbpref . "words where WoID = " . $wid); $oldtransarr = preg_split('/[' . get_sepas() . ']/u', $oldtrans); array_walk($oldtransarr, 'trim_value'); if (!in_array($data, $oldtransarr)) { if (trim($oldtrans) == '' || trim($oldtrans) == '*') { $oldtrans = $data; } else { $oldtrans .= ' ' . get_first_sepa() . ' ' . $data; } $dummy = runsql('update ' . $tbpref . 'words set ' . 'WoTranslation = ' . convert_string_to_sqlsyntax($oldtrans) . ' where WoID = ' . $wid, ""); } $success = get_first_value("select WoTextLC as value from " . $tbpref . "words where WoID = " . $wid); } } echo $success;