Пример #1
0
    $sql2 = sprintf("SELECT COUNT(*) FROM words WHERE {$language} LIKE '%%%s%%' ORDER BY italian, grammar", $phrase_replace);
} elseif ($match == "exact") {
    $sql = sprintf("SELECT italian, pronunciation, grammar, translation FROM words WHERE {$language} = '%s' ORDER BY italian, grammar", addslashes($phrase));
    $sql2 = sprintf("SELECT COUNT(*) FROM words WHERE {$language} = '%s' ORDER BY italian, grammar", addslashes($phrase));
}
//if there is nothing returned then let the user know and the script will end;
$result2 = mysql_query($sql2) or die("The server cannot be reached at this time.");
$display2 = mysql_fetch_row($result2) or die("The server cannot be reached at this time.");
if ($display2[0] == 0) {
    echo "<p>There are no records found for <strong style=\"color: #000;\">" . $phrase . "</strong></p>";
    #strip slashes since they were added to query the db;
    #add the missing word into a db table and then send me an email if there are more than 'x' new searched phrases;
    $arr = array("phrase" => $phrase, "language" => $language, "ip" => $_SERVER['REMOTE_ADDR']);
    $cfg = new ItalyDAO($arr);
    $cfg->addWordSearch();
    if ($cfg->getCount("word_search") > 9) {
        $result = mysql_query("SELECT * FROM word_search");
        $all_words = array();
        while ($display = mysql_fetch_assoc($result)) {
            $all_words[] = "\nword: " . $display['word'] . "\nlanguage: " . $display['language'] . "\nip: " . $display['ip'] . "\ntimestamp: " . $display['timestamp'];
        }
        $cfg->sendEmail((object) array("message" => "Here are the latest searched words:\n\n" . join("\n", $all_words), "subject" => "italy.benjamintoll.com searched words list", "mail_to" => "*****@*****.**", "mail_from" => "*****@*****.**"));
    }
} else {
    //there are records found so print the results;
    //$result = mysql_query($sql) or die("The server cannot be reached at this time.");
    $result = mysql_query($sql);
    //this function counts the results in the array and displays the result
    //on the page along with the word searched for;
    $num_results = mysql_num_rows($result);
    if ($num_results > 250) {
Пример #2
0
<?php

$body_id = "dictionary";
include_once "/home/benjamin/public_html/italy/lib/php/config.php";
include_once HEADER;
#include_once("lib/php/search_engines.php");
$dict = new ItalyDAO();
?>

  <div id="text">
    <form id="dictionaryForm" method="get" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
">
      <p>There are <b><?php 
echo htmlentities($dict->getCount("words"));
?>
</b> words and expressions in the database.</p>
      <h4>Enter a word to get its translation:</h4>
      <label><input type="text" name="phrase" id="phrase" class="text" /></label>
      <label><input type="radio" name="match" value="like" checked="checked" /> Must Contain Entire Phrase, In Exact Order</label>
      <label><input type="radio" name="match" value="each_word" /> Must Contain Each Word In Phrase, In Any Order</label>
      <label><input type="radio" name="match" value="exact" /> Exact Match - Entire Phrase</label>
      <hr />
      <h4>The above text is in:</h4>
      <label><input type="radio" name="language" value="italian" checked="checked" /> Italian</label>
      <label><input type="radio" name="language" value="english" /> English</label>
      <p><label><input class="submit" type="submit" value="Search" /></label> <label><input class="submit" type="reset" id="reset" name="reset" value="Clear" /></label></p>

      <div id="displayWords">
        <?php