Beispiel #1
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);
    }
}
 function value()
 {
     global $sql_stmts;
     if ($this->issql and $this->_id !== NULL) {
         sql_getone(sql_stmt("pron_id->pron_value"), $this->_value, ["i", &$this->_id]);
     }
     # still NULL if not found
     return $this->_value;
 }
Beispiel #3
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()];
 }
Beispiel #4
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 
}
Beispiel #5
0
 function path_by_tag()
 {
     global $sql_stmts;
     $_id = NULL;
     $tag = func_get_args();
     $p = PATH($this, $tag);
     if ($this->issql) {
         $tag = (string) $p;
         sql_getone(sql_stmt("word_id,form_tag->form_id"), $_id, ["is", $this->_id, $tag]);
         if ($_id !== NULL) {
             return PATH($this, $_id);
         }
     }
     if ($p->exists()) {
         return $p;
     }
 }
Beispiel #6
0
 function max_size()
 {
     global $mysqli;
     $stmt = $this->stmt;
     $stmt = str_replace("SELECT word_id FROM words", "SELECT count(*) FROM words", $stmt);
     $value = $stmt;
     $stmt = $mysqli->prepare($stmt);
     if (!$stmt) {
         echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
         echo "\nStatement was: " . var_export($value, 1);
     }
     $ret = sql_getone($stmt, $this->map, $this->args);
     $stmt->close();
     return $ret;
 }
<?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");
}
Beispiel #8
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;
}
Beispiel #9
0
$max_id = NULL;
$ids = NULL;
$names = NULL;
if ($table2 != $table) {
    $stmt = $mysqli->prepare("DROP TABLE IF EXISTS {$table2}");
    sql_exec($stmt, []);
    $stmt->close();
    $stmt = $mysqli->prepare("CREATE TABLE {$table2} like {$table}");
    sql_exec($stmt, []);
    $stmt->close();
    $stmt = $mysqli->prepare("INSERT {$table2} SELECT * FROM {$table}");
    sql_exec($stmt, []);
    $stmt->close();
}
$stmt = $mysqli->prepare("SELECT MAX({$column}) FROM {$table2}");
sql_getone($stmt, $max_id, []);
$stmt->close();
$stmt = $mysqli->prepare("SELECT {$column} FROM {$table2} ORDER BY {$order}");
sql_getmany($stmt, $ids, []);
$stmt->close();
$stmt = $mysqli->prepare("SELECT word_name FROM {$table2} ORDER BY {$order}");
sql_getmany($stmt, $names, []);
$stmt->close();
$safe = $max_id + 1;
if ($safe < 1000) {
    $safe = 1000;
}
echo $max_id . "," . $safe . "<br>";
foreach ($names as $id => $name) {
    //if($e)echo ($id+1)." “".$name."”<br>";
}