Esempio n. 1
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>
Esempio n. 2
0
    $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>
Esempio n. 3
0
File: index.php Progetto: Fips11/lwt
}
// ********* 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">&nbsp;</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;
?>
Esempio n. 4
0
function check_update_db()
{
    global $debug, $tbpref;
    $tables = array();
    $res = do_mysql_query(str_replace('_', "\\_", "SHOW TABLES LIKE " . convert_string_to_sqlsyntax_nonull($tbpref . '%')));
    while ($row = mysql_fetch_row($res)) {
        $tables[] = $row[0];
    }
    mysql_free_result($res);
    $count = 0;
    // counter for cache rebuild
    // Rebuild Tables if missing (current versions!)
    if (in_array($tbpref . 'archivedtexts', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding archivedtexts</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "archivedtexts ( AtID int(11) unsigned NOT NULL AUTO_INCREMENT, AtLgID int(11) unsigned NOT NULL, AtTitle varchar(200) NOT NULL, AtText text NOT NULL, AtAnnotatedText longtext NOT NULL, AtAudioURI varchar(200) DEFAULT NULL, AtSourceURI varchar(1000) DEFAULT NULL, PRIMARY KEY (AtID), KEY AtLgID (AtLgID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array($tbpref . 'languages', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding languages</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "languages ( LgID int(11) unsigned NOT NULL AUTO_INCREMENT, LgName varchar(40) NOT NULL, LgDict1URI varchar(200) NOT NULL, LgDict2URI varchar(200) DEFAULT NULL, LgGoogleTranslateURI varchar(200) DEFAULT NULL, LgExportTemplate varchar(1000) DEFAULT NULL, LgTextSize int(5) unsigned NOT NULL DEFAULT '100', LgCharacterSubstitutions varchar(500) NOT NULL, LgRegexpSplitSentences varchar(500) NOT NULL, LgExceptionsSplitSentences varchar(500) NOT NULL, LgRegexpWordCharacters varchar(500) NOT NULL, LgRemoveSpaces int(1) unsigned NOT NULL DEFAULT '0', LgSplitEachChar int(1) unsigned NOT NULL DEFAULT '0', LgRightToLeft int(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (LgID), UNIQUE KEY LgName (LgName) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array($tbpref . 'sentences', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding sentences</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "sentences ( SeID int(11) unsigned NOT NULL AUTO_INCREMENT, SeLgID int(11) unsigned NOT NULL, SeTxID int(11) unsigned NOT NULL, SeOrder int(11) unsigned NOT NULL, SeText text, PRIMARY KEY (SeID), KEY SeLgID (SeLgID), KEY SeTxID (SeTxID), KEY SeOrder (SeOrder) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
        $count++;
    }
    if (in_array($tbpref . 'settings', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding settings</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "settings ( StKey varchar(40) NOT NULL, StValue varchar(40) DEFAULT NULL, PRIMARY KEY (StKey) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array($tbpref . 'textitems', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding textitems</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS " . $tbpref . "textitems ( TiID int(11) unsigned NOT NULL AUTO_INCREMENT, TiLgID int(11) unsigned NOT NULL, TiTxID int(11) unsigned NOT NULL, TiSeID int(11) unsigned NOT NULL, TiOrder int(11) unsigned NOT NULL, TiWordCount int(1) unsigned NOT NULL, TiText varchar(250) NOT NULL, TiTextLC varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, TiIsNotWord tinyint(1) NOT NULL, PRIMARY KEY (TiID), KEY TiLgID (TiLgID), KEY TiTxID (TiTxID), KEY TiSeID (TiSeID), KEY TiOrder (TiOrder), KEY TiTextLC (TiTextLC), KEY TiIsNotWord (TiIsNotWord) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
        $count++;
    }
    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} --&gt; {$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);
    }
}