本文整理汇总了PHP中make_score_random_insert_update函数的典型用法代码示例。如果您正苦于以下问题:PHP make_score_random_insert_update函数的具体用法?PHP make_score_random_insert_update怎么用?PHP make_score_random_insert_update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_score_random_insert_update函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: word
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;
?>
示例2: Known
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
示例3: runsql
// update
$msg1 = runsql('delete from ' . $tbpref . 'words where WoLgID = ' . $lang . ' and WoTextLC=' . convert_string_to_sqlsyntax($wl), "Exists, deleted");
runsql("DELETE " . $tbpref . "wordtags FROM (" . $tbpref . "wordtags LEFT JOIN " . $tbpref . "words on WtWoID = WoID) WHERE WoID IS NULL", '');
$msg2 = runsql('insert into ' . $tbpref . 'words (WoLgID, WoTextLC, WoText, WoStatus, WoTranslation, WoRomanization, WoSentence, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values ( ' . $lang . ', ' . convert_string_to_sqlsyntax($wl) . ', ' . convert_string_to_sqlsyntax($w) . ', ' . $status . ', ' . convert_string_to_sqlsyntax($t) . ', ' . convert_string_to_sqlsyntax($r) . ', ' . convert_string_to_sqlsyntax($s) . ', NOW(), ' . make_score_random_insert_update('id') . ')', "Imported");
$wid = get_last_key();
array_walk($g, 'savetag', $wid);
$sqlct++;
$protokoll .= '<td class="td1">' . tohtml($msg1 . ' / ' . $msg2) . ' (' . $sqlct . ')</td></tr>';
} else {
// no overwrite
$protokoll .= '<td class="td1"><span class="red2">EXISTS, NOT IMPORTED</span></td></tr>';
}
// no overwrite
} else {
// exists not
$msg1 = runsql('insert into ' . $tbpref . 'words (WoLgID, WoTextLC, WoText, WoStatus, WoTranslation, WoRomanization, WoSentence, WoStatusChanged,' . make_score_random_insert_update('iv') . ') values ( ' . $lang . ', ' . convert_string_to_sqlsyntax($wl) . ', ' . convert_string_to_sqlsyntax($w) . ', ' . $status . ', ' . convert_string_to_sqlsyntax($t) . ', ' . convert_string_to_sqlsyntax($r) . ', ' . convert_string_to_sqlsyntax($s) . ', NOW(), ' . make_score_random_insert_update('id') . ')', "Imported");
$wid = get_last_key();
array_walk($g, 'savetag', $wid);
$sqlct++;
$protokoll .= '<td class="td1">' . tohtml($msg1) . ' (' . $sqlct . ')' . '</td></tr>';
}
} else {
$protokoll .= '<td class="td1"><span class="red2">NOT IMPORTED (term and/or translation missing)</span></td></tr>';
}
}
// for ($i=0; $i<$l; $i++)
echo '<p class="red">*** Imported terms: ' . $sqlct . ' of ' . $l . ' *** ' . errorbutton('Error') . '</p>';
$protokoll .= '</table>';
echo $protokoll;
} else {
$message = 'Error: Wrong Operation: ' . $_REQUEST['op'];
示例4: runsql
} 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
示例5: get_first_value
if ($stchange > 0) {
$stchange = 1;
}
} else {
$stchange = $stchange + 0;
$status = $oldstatus + $stchange;
if ($status < 1) {
$status = 1;
}
if ($status > 5) {
$status = 5;
}
}
$word = get_first_value("select WoText as value from words where WoID = " . $wid);
pagestart("Term: " . $word, false);
$m1 = runsql('update words set WoStatus = ' . $status . ', WoStatusChanged = NOW(),' . make_score_random_insert_update('u') . ' where WoID = ' . $wid, 'Status changed');
$newscore = get_first_value('select greatest(0,round(WoTodayScore,0)) AS value from words where WoID = ' . $wid) + 0;
if ($oldstatus == $status) {
echo '<p>Status ' . get_colored_status_msg($status) . ' not changed.</p>';
} else {
echo '<p>Status changed from ' . get_colored_status_msg($oldstatus) . ' to ' . get_colored_status_msg($status) . '.</p>';
}
echo "<p>Old score was " . $oldscore . ", new score is now " . $newscore . ".</p>";
$totaltests = $_SESSION['testtotal'];
$wrong = $_SESSION['testwrong'];
$correct = $_SESSION['testcorrect'];
$notyettested = $totaltests - $correct - $wrong;
if ($notyettested > 0) {
if ($stchange >= 0) {
$_SESSION['testcorrect']++;
} else {
示例6: trim
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>
示例7: trim
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;
}
?>
示例8: check_update_db
//.........这里部分代码省略.........
if (in_array($tbpref . 'texts', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding texts</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "texts ( TxID int(11) unsigned NOT NULL AUTO_INCREMENT, TxLgID int(11) unsigned NOT NULL, TxTitle varchar(200) NOT NULL, TxText text NOT NULL, TxAnnotatedText longtext NOT NULL, TxAudioURI varchar(200) DEFAULT NULL, TxSourceURI varchar(1000) DEFAULT NULL, PRIMARY KEY (TxID), KEY TxLgID (TxLgID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array($tbpref . 'words', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding words</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "words ( WoID int(11) unsigned NOT NULL AUTO_INCREMENT, WoLgID int(11) unsigned NOT NULL, WoText varchar(250) NOT NULL, WoTextLC varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, WoStatus tinyint(4) NOT NULL, WoTranslation varchar(500) NOT NULL DEFAULT '*', WoRomanization varchar(100) DEFAULT NULL, WoSentence varchar(1000) DEFAULT NULL, WoCreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, WoStatusChanged timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', WoTodayScore double NOT NULL DEFAULT '0', WoTomorrowScore double NOT NULL DEFAULT '0', WoRandom double NOT NULL DEFAULT '0', PRIMARY KEY (WoID), UNIQUE KEY WoLgIDTextLC (WoLgID,WoTextLC), KEY WoLgID (WoLgID), KEY WoStatus (WoStatus), KEY WoTextLC (WoTextLC), KEY WoTranslation (WoTranslation(333)), KEY WoCreated (WoCreated), KEY WoStatusChanged (WoStatusChanged), KEY WoTodayScore (WoTodayScore), KEY WoTomorrowScore (WoTomorrowScore), KEY WoRandom (WoRandom) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array($tbpref . 'tags', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding tags</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "tags ( TgID int(11) unsigned NOT NULL AUTO_INCREMENT, TgText varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, TgComment varchar(200) NOT NULL DEFAULT '', PRIMARY KEY (TgID), UNIQUE KEY TgText (TgText) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array($tbpref . 'wordtags', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding wordtags</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "wordtags ( WtWoID int(11) unsigned NOT NULL, WtTgID int(11) unsigned NOT NULL, PRIMARY KEY (WtWoID,WtTgID), KEY WtTgID (WtTgID), KEY WtWoID (WtWoID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array($tbpref . 'tags2', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding tags2</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "tags2 ( T2ID int(11) unsigned NOT NULL AUTO_INCREMENT, T2Text varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, T2Comment varchar(200) NOT NULL DEFAULT '', PRIMARY KEY (T2ID), UNIQUE KEY T2Text (T2Text) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array($tbpref . 'texttags', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding texttags</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "texttags ( TtTxID int(11) unsigned NOT NULL, TtT2ID int(11) unsigned NOT NULL, PRIMARY KEY (TtTxID,TtT2ID), KEY TtTxID (TtTxID), KEY TtT2ID (TtT2ID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array($tbpref . 'archtexttags', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding archtexttags</p>';
}
runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "archtexttags ( AgAtID int(11) unsigned NOT NULL, AgT2ID int(11) unsigned NOT NULL, PRIMARY KEY (AgAtID,AgT2ID), KEY AgAtID (AgAtID), KEY AgT2ID (AgT2ID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if ($count > 0) {
// Rebuild Text Cache if cache tables new
if ($debug) {
echo '<p>DEBUG: rebuilding cache tables</p>';
}
reparse_all_texts();
}
// DB Version
$currversion = get_version_number();
$res = mysql_query("select StValue as value from " . $tbpref . "settings where StKey = 'dbversion'");
if (mysql_errno() != 0) {
my_die('There is something wrong with your database ' . $dbname . '. Please reinstall.');
}
$record = mysql_fetch_assoc($res);
if ($record) {
$dbversion = $record["value"];
} else {
$dbversion = 'v001000000';
}
mysql_free_result($res);
// Do DB Updates if tables seem to be old versions
if ($dbversion < $currversion) {
if ($debug) {
echo "<p>DEBUG: do DB updates: {$dbversion} --> {$currversion}</p>";
}
runsql("ALTER TABLE " . $tbpref . "words ADD WoTodayScore DOUBLE NOT NULL DEFAULT 0, ADD WoTomorrowScore DOUBLE NOT NULL DEFAULT 0, ADD WoRandom DOUBLE NOT NULL DEFAULT 0", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "words ADD INDEX WoTodayScore (WoTodayScore), ADD INDEX WoTomorrowScore (WoTomorrowScore), ADD INDEX WoRandom (WoRandom)", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "languages ADD LgRightToLeft INT(1) UNSIGNED NOT NULL DEFAULT 0", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "texts ADD TxAnnotatedText LONGTEXT NOT NULL AFTER TxText", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "archivedtexts ADD AtAnnotatedText LONGTEXT NOT NULL AFTER AtText", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "tags CHANGE TgComment TgComment VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "tags2 CHANGE T2Comment T2Comment VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "languages CHANGE LgGoogleTTSURI LgExportTemplate VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "texts ADD TxSourceURI VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", '', $sqlerrdie = FALSE);
runsql("ALTER TABLE " . $tbpref . "archivedtexts ADD AtSourceURI VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", '', $sqlerrdie = FALSE);
// set to current.
saveSetting('dbversion', $currversion);
saveSetting('lastscorecalc', '');
// do next section, too
}
// Do Scoring once per day, clean Word/Texttags, and optimize db
$lastscorecalc = getSetting('lastscorecalc');
$today = date('Y-m-d');
if ($lastscorecalc != $today) {
if ($debug) {
echo '<p>DEBUG: Doing score recalc. Today: ' . $today . ' / Last: ' . $lastscorecalc . '</p>';
}
runsql("UPDATE " . $tbpref . "words SET " . make_score_random_insert_update('u'), '');
runsql("DELETE " . $tbpref . "wordtags FROM (" . $tbpref . "wordtags LEFT JOIN " . $tbpref . "tags on WtTgID = TgID) WHERE TgID IS NULL", '');
runsql("DELETE " . $tbpref . "wordtags FROM (" . $tbpref . "wordtags LEFT JOIN " . $tbpref . "words on WtWoID = WoID) WHERE WoID IS NULL", '');
runsql("DELETE " . $tbpref . "texttags FROM (" . $tbpref . "texttags LEFT JOIN " . $tbpref . "tags2 on TtT2ID = T2ID) WHERE T2ID IS NULL", '');
runsql("DELETE " . $tbpref . "texttags FROM (" . $tbpref . "texttags LEFT JOIN " . $tbpref . "texts on TtTxID = TxID) WHERE TxID IS NULL", '');
runsql("DELETE " . $tbpref . "archtexttags FROM (" . $tbpref . "archtexttags LEFT JOIN " . $tbpref . "tags2 on AgT2ID = T2ID) WHERE T2ID IS NULL", '');
runsql("DELETE " . $tbpref . "archtexttags FROM (" . $tbpref . "archtexttags LEFT JOIN " . $tbpref . "archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", '');
optimizedb();
saveSetting('lastscorecalc', $today);
}
}
示例9: trim
require_once 'settings.inc.php';
require_once 'connect.inc.php';
require_once 'dbutils.inc.php';
require_once 'utilities.inc.php';
$wid = $_POST['id'] + 0;
$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, "");
示例10: runsql
}
// 98->1
if ($currstatus == 6) {
$currstatus = 99;
}
// 5->99
} else {
$currstatus -= 1;
// 1,2,3,4,5,99 => 0,1,2,3,4,98
if ($currstatus == 98) {
$currstatus = 5;
}
// 99->5
if ($currstatus == 0) {
$currstatus = 98;
}
// 1->98
}
if ($currstatus >= 1 && $currstatus <= 5 || $currstatus == 99 || $currstatus == 98) {
$m1 = runsql('update ' . $tbpref . 'words set WoStatus = ' . $currstatus . ', WoStatusChanged = NOW(),' . make_score_random_insert_update('u') . ' where WoID = ' . $wid, '') + 0;
if ($m1 == 1) {
$currstatus = get_first_value('SELECT WoStatus as value FROM ' . $tbpref . 'words where WoID = ' . $wid);
if (!isset($currstatus)) {
echo '';
}
echo make_status_controls_test_table(1, $currstatus, $wid);
}
} else {
echo '';
}
}
示例11: check_update_db
//.........这里部分代码省略.........
}
if (in_array('texttags', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding texttags</p>';
}
runsql("CREATE TABLE IF NOT EXISTS texttags ( TtTxID int(11) unsigned NOT NULL, TtT2ID int(11) unsigned NOT NULL, PRIMARY KEY (TtTxID,TtT2ID), KEY TtTxID (TtTxID), KEY TtT2ID (TtT2ID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if (in_array('archtexttags', $tables) == FALSE) {
if ($debug) {
echo '<p>DEBUG: rebuilding archtexttags</p>';
}
runsql("CREATE TABLE IF NOT EXISTS archtexttags ( AgAtID int(11) unsigned NOT NULL, AgT2ID int(11) unsigned NOT NULL, PRIMARY KEY (AgAtID,AgT2ID), KEY AgAtID (AgAtID), KEY AgT2ID (AgT2ID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
}
if ($count > 0) {
// Rebuild Text Cache if cache tables new
if ($debug) {
echo '<p>DEBUG: rebuilding cache tables</p>';
}
$sql = "select TxID, TxLgID from texts";
$res = mysql_query($sql);
if ($res == FALSE) {
die("Invalid Query: {$sql}");
}
while ($record = mysql_fetch_assoc($res)) {
$id = $record['TxID'];
runsql('delete from sentences where SeTxID = ' . $id, "");
runsql('delete from textitems where TiTxID = ' . $id, "");
adjust_autoincr('sentences', 'SeID');
adjust_autoincr('textitems', 'TiID');
splitText(get_first_value('select TxText as value from texts where TxID = ' . $id), $record['TxLgID'], $id);
}
mysql_free_result($res);
}
// Version
$res = mysql_query("select StValue as value from settings where StKey = 'dbversion'");
if (mysql_errno() != 0) {
die('There is something wrong with your database ' . $dbname . '. Please reinstall.');
}
$record = mysql_fetch_assoc($res);
if ($record) {
$dbversion = $record["value"];
} else {
$dbversion = 'v001000000';
saveSetting('dbversion', $dbversion);
if ($debug) {
echo '<p>DEBUG: DB version not found, set to: ' . $dbversion . '</p>';
}
}
mysql_free_result($res);
// Do DB Updates
$currversion = get_version_number();
if ($currversion > $dbversion) {
if ($currversion > 'v001000000') {
// updates for all versions > 1.0.0
if ($debug) {
echo '<p>DEBUG: Doing db-upgrade ' . $currversion . ' > v001000000</p>';
}
runsql("ALTER TABLE words ADD WoTodayScore DOUBLE NOT NULL DEFAULT 0, ADD WoTomorrowScore DOUBLE NOT NULL DEFAULT 0, ADD WoRandom DOUBLE NOT NULL DEFAULT 0", '');
runsql("ALTER TABLE words ADD INDEX WoTodayScore (WoTodayScore), ADD INDEX WoTomorrowScore (WoTomorrowScore), ADD INDEX WoRandom (WoRandom)", '');
runsql("UPDATE words SET " . make_score_random_insert_update('u'), '');
}
if ($currversion > 'v001001001') {
if ($debug) {
echo '<p>DEBUG: Doing db-upgrade ' . $currversion . ' > v001001001</p>';
}
// updates for all versions > 1.1.1 :
// New: Table "tags", created above
// New: Table "wordtags", created above
}
if ($currversion > 'v001002002') {
if ($debug) {
echo '<p>DEBUG: Doing db-upgrade ' . $currversion . ' > v001002002</p>';
}
// updates for all versions > 1.2.2 :
// New: Table "tags2", created above
// New: Table "texttags", created above
// New: Table "archtexttags", created above
runsql("ALTER TABLE languages ADD LgRightToLeft INT(1) UNSIGNED NOT NULL DEFAULT 0", '');
}
// set to current.
saveSetting('dbversion', $currversion);
}
// Do Scoring once per day, clean Word/Texttags, and optimize db
$lastscorecalc = getSetting('lastscorecalc');
$today = date('Y-m-d');
if ($lastscorecalc != $today) {
if ($debug) {
echo '<p>DEBUG: Doing score recalc. Today: ' . $today . ' / Last: ' . $lastscorecalc . '</p>';
}
runsql("UPDATE words SET " . make_score_random_insert_update('u'), '');
runsql("DELETE wordtags FROM (wordtags LEFT JOIN tags on WtTgID = TgID) WHERE TgID IS NULL", '');
runsql("DELETE wordtags FROM (wordtags LEFT JOIN words on WtWoID = WoID) WHERE WoID IS NULL", '');
runsql("DELETE texttags FROM (texttags LEFT JOIN tags2 on TtT2ID = T2ID) WHERE T2ID IS NULL", '');
runsql("DELETE texttags FROM (texttags LEFT JOIN texts on TtTxID = TxID) WHERE TxID IS NULL", '');
runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN tags2 on AgT2ID = T2ID) WHERE T2ID IS NULL", '');
runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", '');
optimizedb();
saveSetting('lastscorecalc', $today);
}
}
示例12: do_mysql_query
$tid = $_REQUEST['tid'];
$wid = $_REQUEST['wid'];
$status = $_REQUEST['status'];
$sql = 'SELECT WoText, WoTranslation, WoRomanization FROM ' . $tbpref . 'words where WoID = ' . $wid;
$res = do_mysql_query($sql);
$record = mysql_fetch_assoc($res);
if ($record) {
$word = $record['WoText'];
$trans = repl_tab_nl($record['WoTranslation']) . getWordTagList($wid, ' ', 1, 0);
$roman = $record['WoRomanization'];
} else {
my_die("Word not found in set_word_status.php");
}
mysql_free_result($res);
pagestart("Term: " . $word, false);
$m1 = runsql('update ' . $tbpref . 'words set WoStatus = ' . $_REQUEST['status'] . ', WoStatusChanged = NOW(),' . make_score_random_insert_update('u') . ' where WoID = ' . $wid, 'Status changed');
echo '<p>OK, this term has status ' . get_colored_status_msg($status) . ' from now!</p>';
?>
<script type="text/javascript">
//<![CDATA[
var context = window.parent.frames['l'].document;
var contexth = window.parent.frames['h'].document;
var status = '<?php
echo $status;
?>
';
var title = make_tooltip(<?php
echo prepare_textdata_js($word);
?>
, <?php
echo prepare_textdata_js($trans);