Exemplo n.º 1
0
function add_word($name)
{
    global $sql_stmts;
    $w = defaultDB()->searcher()->name($name)->spart("verb")->lang("la")->all();
    if (count($w)) {
        echo "Word seems to be already added: {$name}<br>";
        if (count($w) === 1) {
            $w = $w[0];
            if ($w->read_paths()) {
                echo "- Had inflection already<br>";
            } else {
                return $w;
            }
        } else {
            echo "- More than one found, continuing<br>";
        }
    } else {
        echo "Adding word: {$name}<br>";
        sql_exec(sql_stmt("word_lang,word_name,word_spart->new in words"), ["sss", "la", $name, "verb"]);
        $w = defaultDB()->searcher()->name($name)->spart("verb")->lang("la")->all();
        if (count($w) === 1) {
            $w = $w[0];
            return $w;
        }
    }
}
Exemplo n.º 2
0
function make_word($name, $jp = NULL, $zh = NULL)
{
    global $sql_stmts;
    sql_exec(sql_stmt("word_lang,word_name,word_spart->new in words"), ["sss", "tp", $name, "multi"]);
    $id = NULL;
    sql_getone(sql_stmt("word_lang,word_name,word_spart->word_id"), $id, ["sss", "tp", $name, "multi"]);
    $GLOBALS["word"] = WORD(defaultDB(), $id);
    if ($jp) {
        $a = ATTR("jp", $jp);
        $GLOBALS["word"]->add_attr($a);
    }
    if ($zh) {
        $a = ATTR("zh", $jp);
        $GLOBALS["word"]->add_attr($a);
    }
}
Exemplo n.º 3
0
function add_word($name)
{
    global $sql_stmts;
    $w = defaultDB()->searcher()->name($name)->spart("verb")->lang("la")->all();
    if (count($w)) {
        echo "Word seems to be already added: {$name}<br>";
        return NULL;
    } else {
        echo "Adding word: {$name}<br>";
        sql_exec(sql_stmt("word_lang,word_name,word_spart->new in words"), ["sss", "la", $name, "verb"]);
        $w = defaultDB()->searcher()->name($name)->spart("verb")->lang("la")->all();
        if (count($w) === 1) {
            $w = $w[0];
            return $w;
        }
    }
}
Exemplo n.º 4
0
 function set_value($value)
 {
     global $sql_stmts;
     $this->_value = $value;
     if ($this->issql and $this->_id !== NULL) {
         sql_set(sql_stmt("pron_id->pron_value="), $this->_value, ["i", &$this->_id]);
     }
 }
Exemplo n.º 5
0
    if (!array_key_exists("name", $_GET)) {
        $_GET["name"] = NULL;
    }
    if (!array_key_exists("spart", $_GET)) {
        $_GET["spart"] = NULL;
    }
    foreach ($_GET as $k => $v) {
        if (!startswith($k, "delete_")) {
            continue;
        }
        if ($v != "true") {
            continue;
        }
        $id = explode("_", $k, 2)[1];
        $id = intval($id);
        sql_exec(sql_stmt("form_id->delete from forms"), ["i", $id]);
    }
    $list = $db->find_all_words($_GET["name"], $_GET["lang"], $_GET["spart"]);
    foreach ($list as $w) {
        ?>
<ul><?php 
        display_word_info($w);
        ?>
<br><?php 
        $id = $w->id();
        $w->read_paths();
        foreach ($w->paths() as $path) {
            echo "<li>[" . $path->id() . "] ({$path})" . $path->value();
            echo " <button onclick='moveloc(" . $path->id() . ")'>Delete</button><br>";
        }
        ?>
Exemplo n.º 6
0
}
$definitions = safe_get("definitions", $_GET);
$connections = safe_get("connections", $_GET);
$forms = safe_get("forms", $_GET);
if (!requireRank(3, FALSE)) {
    echo "Insufficient permissions";
} else {
    if ($langs and count($langs) == 1 and $names and count($names) == 1 and $sparts and count($sparts) == 1) {
        $w = defaultDB()->searcher()->name($names[0])->spart($sparts[0])->lang($langs[0])->all();
        if (count($w)) {
            exit("Word seems to be already added. <a href='/dictionary.php?lang={$langs[0]}&spart={$sparts[0]}&name={$names[0]}' target='_blank'>See it</a>");
        }
        if (!$definitions or !count($definitions)) {
            exit("Please enter at least one definition");
        }
        sql_exec(sql_stmt("word_lang,word_name,word_spart->new in words"), ["sss", $langs[0], $names[0], $sparts[0]]);
        $w = defaultDB()->searcher()->name($names[0])->spart($sparts[0])->lang($langs[0])->all();
        if (count($w) === 1) {
            $w = $w[0];
            foreach ($attrs as $a) {
                error_log($a);
                $a = explode("=", $a, 2);
                if (count($a) === 2) {
                    $w->add_attr(ATTR($a[0], $a[1]));
                }
            }
            foreach ($definitions as $d) {
                $dd = DEFINITION(defaultDB(), NULL, $w);
                $dd->set_lang("en");
                $dd->set_value($d);
                $w->add_definition($dd);
Exemplo n.º 7
0
    <table style="border-spacing: 8px 2px;">
    <tr><th>Select</th>
    <?php 
if ($master) {
    echo "<th>UserName</th>";
}
?>
    <th>Name</th><th>Score/Grade</th><th>Date</th></tr>
    <?php 
global $sql_stmts;
$quizzes = [];
$quizzes_data = [];
if ($master) {
    sql_getmany(sql_stmt("all quizzes"), $quizzes, []);
} else {
    sql_getmany(sql_stmt("user_id->quiz_id reversed"), $quizzes, ["i", $suid]);
}
foreach ($quizzes as &$q) {
    $q = QUIZ($q);
    $quizzes_data[$q->id()] = $q->completed();
    ?>
<tr>
            <td><input name="quizzes" type="radio" value="<?php 
    echo $q->id();
    ?>
"></td>
            <?php 
    if ($master) {
        echo "<td>" . $q->username() . "</td>";
    }
    ?>
Exemplo n.º 8
0
 function data()
 {
     $questions = NULL;
     $results = NULL;
     sql_getone(sql_stmt("quiz_id->questions"), $questions, ["i", &$this->_id]);
     if (!$questions) {
         $questions = "[]";
     }
     $questions = json_decode($questions);
     sql_getone(sql_stmt("quiz_id->results"), $results, ["i", &$this->_id]);
     if (!$results) {
         $results = "[]";
     }
     $results = json_decode($results);
     return ["questions" => $questions, "results" => $results, "last" => $this->last(), "score" => $this->score(), "out_of" => $this->out_of(), "completed" => $this->completed(), "mode" => $this->mode(), "id" => $this->id()];
 }
Exemplo n.º 9
0
$db = defaultDB();
if (safe_get("lang", $_GET)) {
    $langs = [$_GET["lang"]];
} else {
    $langs = ['la'];
}
?>
<select><?php 
foreach ($db->langs() as $l) {
    $name = $l;
    sql_getone(sql_stmt("lang_id->#words"), $words, ["s", $l]);
    $c = count($words);
    if ($words < 10) {
        continue;
    }
    sql_getone(sql_stmt("lang_id->lang_dispname"), $name, ["s", $l]);
    ?>
<option <?php 
    if (in_array($l, $langs)) {
        ?>
selected<?php 
    }
    ?>
 value="<?php 
    echo $l;
    ?>
" ><?php 
    echo $name;
    ?>
</option><?php 
}
Exemplo n.º 10
0
 function remove()
 {
     global $sql_stmts;
     if ($this->issql and $this->_id !== NULL) {
         return sql_exec(sql_stmt("word_id->delete from words"), ["i", &$this->_id]);
     }
     # still NULL if not found
 }
Exemplo n.º 11
0
 function sparts()
 {
     global $sql_stmts;
     $res = NULL;
     sql_getmany(sql_stmt("all_sparts"), $res, []);
     if ($res) {
         $res = array_unique($res);
     }
     return $res;
 }
Exemplo n.º 12
0
 function remove($hash = NULL)
 {
     global $sql_stmts;
     if ($this->issql and $this->_id !== NULL) {
         sql_exec(sql_stmt("form_id->delete from forms"), ["i", &$this->_id]);
     }
     $hash =& $this->resolve_hash($hash);
     if (FLAT_STORAGE) {
         $ret = $hash[(string) $this];
         unset($hash[(string) $this]);
         return $ret;
     }
     $h = $this->walk($hash, 0);
     if ($h === NULL) {
         return NULL;
     }
     $this->_map_dirty = 1;
     $r = $h[""];
     unset($h[""]);
     # Clean up dead branches if we have killed them:
     while (!count($h) and count($this)) {
         $max = count($this) - 1;
         list($h2, $i, $k) = $this->walk_part($hash, $max);
         assert('$this->map[$i] == $k');
         assert('$h == $h2[$k]');
         unset($h2[$k]);
         $h = $h2;
     }
     return $r;
 }
Exemplo n.º 13
0
<?php

require_once '/var/www/config.php';
sro('/Includes/mysql.php');
sro('/Includes/session.php');
sro('/Includes/functions.php');
sro('/PHP5/lib/PHPLang/db.php');
sro('/PHP5/lib/PHPLang/sql_stmts.php');
global $sql_stmts;
if (array_key_exists("id", $_GET) and is_numeric($_GET["id"])) {
    $res = NULL;
    sql_getone(sql_stmt("word_id->last_changed"), $res, ["i", $_GET["id"]]);
    if (!$res) {
        exit("word with id {$_GET['id']} did not exist");
    }
    echo $res;
} else {
    exit("\$_GET was invalid");
}
Exemplo n.º 14
0
function format_lang($lang)
{
    global $sql_stmts;
    if (ISWORD($lang)) {
        $lang = $lang->lang();
    }
    $name = $lang;
    sql_getone(sql_stmt("lang_id->lang_dispname"), $name, ["s", $lang]);
    return $name;
}
Exemplo n.º 15
0
 function set_value($value)
 {
     $value = preg_replace('/ {2,}/', ' ', trim($value));
     $this->_value = $value;
     if ($this->issql and $this->_id !== NULL) {
         sql_set(sql_stmt("def_id->def_value="), $this->_value, ["i", &$this->_id]);
     }
 }