} else { // CHECK if ($_REQUEST['op'] == 'Check') { echo '<p><input type="button" value="<< Back" onclick="history.back();" /></p>'; echo splitCheckText(remove_soft_hyphens($_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(remove_soft_hyphens($_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(remove_soft_hyphens($_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(remove_soft_hyphens($_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; } } }
<?php } } } 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++) { $texts[$i] = remove_soft_hyphens($texts[$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 }