function get_mgrW($w) { if (!ISWORD($w)) { $w = WORD($this, $w); } return $this->get_mgr($w->lang(), $w->speechpart()); }
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 find_word_path($word) { $path = array_slice(func_get_args(), 1); if (!ISWORD($word)) { $word = WORD($word); } $p = PATH($word); foreach ($path as $v) { if (!is_vec($v)) { foreach (array_keys($v) as $k) { $path->add($k, $v[$k]); } } else { $path->add($v); } } return $p->get(); }
function __construct($db, $id, $word) { $this->_id = $id; $this->issql = ISSQLDB($db); if ($word === NULL) { $_wid = $this->_getword(); if ($_wid !== NULL) { $word = WORD($db, $_wid); } } $this->_word = $word; if ($_fid = $this->_getpath()) { $this->_path = PATH($this->word(), $_fid); } elseif ($word !== NULL) { $this->_path = PATH($this->word()); } else { $this->_path = NULL; } return $this; }
$dd = DEFINITION(defaultDB(), NULL, $w); $dd->set_lang("en"); $dd->set_value($d); $w->add_definition($dd); } foreach ($connections as $c) { list($type, $other, $mutual) = $c; if (!$type or !$other) { continue; } $other = intval($other); $cc = CONNECTION($w, WORD(defaultDB(), $other), $type); $w->add_connection($cc); if ($mutual === "true") { $cc = CONNECTION(WORD(defaultDB(), $other), $w, $type); WORD(defaultDB(), $other)->add_connection($cc); } } $ignore = []; $changes = []; $path = ""; if ($sparts[0] === "verb") { $template = $_GET["conjugation"] . " " . $_GET["voice"]; if ($_GET["person"] === "impersonal") { $ignore[] = "person-1"; $ignore[] = "person-2"; } else { if ($_GET["person"] === "impersonal-passive") { $ignore[] = "person-1/passive"; $ignore[] = "person-2/passive"; }
} $change = []; if (array_key_exists("change", $_GET)) { $_change = explode(";", $_GET["change"]); foreach ($_change as $str) { list($key, $value) = explode(",", $str); $change[$key] = $value; } } if (array_key_exists("overwrite", $_GET)) { $overwrite = TRUE; } else { $overwrite = FALSE; } // Word as passed by id $w = WORD(defaultDB(), intval($_GET["id"])); // Path as passed as string $p = PATH($w, safe_get("path", $_GET)); // Template: passed by name, spart from word, attr template=true $t = defaultDB()->searcher(); $t = $t->spart($w->speechpart()); $t = $t->name($_GET["template"]); $t = $t->only_with_attr(ATTR("template", "true")); $t = $t->all(); if (count($t) === 0) { echo "Could not find template with name: " . $_GET["template"]; } elseif (count($t) !== 1) { echo "Ambiguous template name (please remove duplicate template(s))"; } else { $t = $t[0]; if (($s = run_template($w, $p, $t, $arg, $ignore, $change, $overwrite)) === NULL) {
<?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'); if (!requireRank(3, FALSE)) { echo "Insufficient permissions"; } else { if (array_key_exists("from", $_GET) and array_key_exists("to", $_GET) and array_key_exists("type", $_GET) and is_numeric($_GET["from"]) and is_numeric($_GET["to"])) { $cons = [[$_GET["from"], $_GET["to"]]]; if (array_key_exists("mutual", $_GET) and $_GET["mutual"] === "true") { $cons = [$cons[0], [$_GET["to"], $_GET["from"]]]; } foreach ($cons as list($ab, $ad)) { $w = WORD(defaultDB(), intval($ab)); $t = WORD(defaultDB(), intval($ad)); $c = CONNECTION($w, $t, $_GET["type"]); $w->add_connection($c); } exit("success"); } else { exit("\$_GET was invalid"); } }
if ($reverse = substr($attr, 0, 1) === "!") { $attr = substr($attr, 1); } if (strpos($attr, "=") === FALSE) { $a = ATTR($attr); } else { list($name, $value) = explode("=", $attr, 2); $a = ATTR($name, $value); } if ($a !== NULL) { if (!$reverse) { $searcher = $searcher->only_with_attr($a); } else { $searcher = $searcher->only_without_attr($a); } } } $list = $searcher->all(); } else { $list = []; foreach ($ids as $id) { $list[] = WORD(defaultDB(), intval($id)); } } $res = vec_norm(array_map(function ($e) { if (no_format($e)) { return ["data" => $e->name(), "value" => $e->id() . "", "display" => $e->info()]; } return ["data" => $e->name(), "value" => $e->id() . "", "display" => format_word($e->info())]; }, $list)); echo json_encode($res);
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/display.php'); if (!hasACL('admin_panel', 'R', 'S')) { sro('/Pages/restricted/admin.php'); die(""); } if (!hasACL('add_words', 'R', 'S')) { sro('/Pages/restricted/adder.php'); die(""); } $uid = cleanInput('/[^0-9]/', $_GET['id']); $word = WORD(defaultDB(), intval($uid)); ?> <h2><?php echo $word->name(); ?> </h2> <div id="aswDetails"> <p> Name: <?php echo $word->name(); ?> <br> Part of speech: <?php echo display_spart($word->spart()); ?> <br>
function connections() { global $sql_stmts; if ($this->issql and $this->_id !== NULL) { $stmt = sql_stmt("from_word_id->to_word_id,connect_type"); if (!$stmt->bind_param("i", $this->_id)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; return $this->_connections; } $stmt->bind_result($to_word_id, $type); if (!$stmt->execute()) { _die("Execute failed (" . __FILE__ . "@" . __LINE__ . "): (" . $stmt->errno . ") " . $stmt->error); return $result; } $added = []; while ($stmt->fetch()) { $added[] = [$to_word_id, $type]; } foreach ($added as $connect) { $this->_connections[] = CONNECTION($this, WORD($this->db(), $connect[0]), $connect[1]); } $stmt->free_result(); $stmt->reset(); } return $this->_connections; }
function all($order_by = NULL) { global $mysqli; if (count($this->args) === 1) { $this->args = []; } if ($order_by !== NULL) { $this->stmt .= " ORDER BY word_{$order_by}"; } if ($this->limit_values !== NULL) { list($start, $limit) = $this->limit_values; $this->stmt .= " LIMIT {$start}, {$limit}"; } $value = $this->stmt; $this->stmt = $mysqli->prepare($this->stmt); if (!$this->stmt) { echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; echo "\nStatement was: " . var_export($value, 1); return; } #error_log($value); sql_getmany($this->stmt, $this->map, $this->args); $this->stmt->close(); #var_dump($this->map, $this->args); #echo "\nStatement was: " . var_export($value, 1); if ($this->map) { foreach ($this->map as &$w) { $w = WORD($this->db, $w); } } return $this->map; }
<?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'); if (!requireRank(3, FALSE)) { echo "Insufficient permissions"; } else { if (array_key_exists("from", $_GET) and array_key_exists("to", $_GET) and array_key_exists("type", $_GET) and is_numeric($_GET["from"]) and is_numeric($_GET["to"])) { $w = WORD(defaultDB(), intval($_GET["from"])); $t = WORD(defaultDB(), intval($_GET["to"])); $c = CONNECTION($w, $t, $_GET["type"]); $w->remove_connection($c); exit("success"); } else { exit("\$_GET was invalid"); } }
sro('/Includes/mysql.php'); sro('/Includes/session.php'); sro('/Includes/functions.php'); sro('/PHP5/lib/PHPLang/common.php'); sro('/PHP5/lib/PHPLang/db.php'); sro('/PHP5/lib/PHPLang/display.php'); global $sql_stmts; $db = defaultDB(); $editor = hasACL('add_words', 'R', 'S'); if (count($_GET)) { if (!array_key_exists("id", $_GET) or !($ids = vec_norm(explode(",", $_GET["id"]), "intval"))) { $ids = []; } if ($ids) { $langs = array_unique(array_map(function ($w) { $word = WORD($w); return $word->lang(); }, $ids)); } else { if (!array_key_exists("lang", $_GET) or !($langs = vec_norm(explode(",", $_GET["lang"]), "trim"))) { $langs = ['la']; } } if ($ids or !array_key_exists("name", $_GET) or !($names = vec_norm(explode(",", $_GET["name"]), "trim"))) { $names = NULL; } if ($ids or !array_key_exists("spart", $_GET) or !($sparts = vec_norm(explode(",", $_GET["spart"]), "trim"))) { $sparts = NULL; } if ($ids or !array_key_exists("attr", $_GET) or !($attrs = vec_norm(explode(",", $_GET["attr"]), "trim"))) { $attrs = [];
function search_GET($limit = 50, &$max_size = NULL) { $db = defaultDB(); if (!array_key_exists("lang", $_GET) or !($langs = vec_norm(explode(",", $_GET["lang"]), "trim"))) { $langs = ['la']; } if (!array_key_exists("name", $_GET) or !($names = vec_norm(explode(",", $_GET["name"]), "trim"))) { $names = NULL; } if (!array_key_exists("form", $_GET) or !($forms = vec_norm(explode(",", $_GET["form"]), "trim"))) { $forms = NULL; } if (!array_key_exists("spart", $_GET) or !($sparts = vec_norm(explode(",", $_GET["spart"]), "trim"))) { $sparts = NULL; } if (!array_key_exists("attr", $_GET) or !($attrs = vec_norm(explode(",", $_GET["attr"]), "trim"))) { $attrs = []; } if (!array_key_exists("def", $_GET) or !($defs = vec_norm(explode(";", $_GET["def"]), "trim"))) { $defs = []; } if (!array_key_exists("id", $_GET) or !($ids = vec_norm(explode(",", $_GET["id"]), "trim"))) { $ids = NULL; } $no_definitions = safe_get("no_definitions", $_GET) === "true"; $no_templates = !(safe_get("show_templates", $_GET) === "true"); $start = intval(safe_get("start", $_GET)); $_ = $limit; $limit = intval(safe_get("limit", $_GET)); if ($limit <= 0) { $limit = 5; } if ($limit > $_) { $limit = $_; } if ($ids === NULL) { $searcher = $db->searcher(); if ($names) { $searcher = $searcher->name($names); } if ($forms) { $searcher = $searcher->form($forms); } if ($langs) { $searcher = $searcher->lang($langs); } if ($sparts) { $searcher = $searcher->spart($sparts); } if ($defs) { $searcher = $searcher->definition_parse($defs); } else { if ($no_definitions) { $searcher = $searcher->no_definitions(); } } if ($no_templates) { $attrs[] = "!template"; } foreach ($attrs as $attr) { if (!$attr) { continue; } $a = NULL; if ($reverse = substr($attr, 0, 1) === "!") { $attr = substr($attr, 1); } if (strpos($attr, "=") === FALSE) { $a = ATTR($attr); } else { list($name, $value) = explode("=", $attr, 2); $a = ATTR($name, $value); } if ($a !== NULL) { if (!$reverse) { $searcher = $searcher->only_with_attr($a); } else { $searcher = $searcher->only_without_attr($a); } } } $max_size = $searcher->max_size(); $list = $searcher->limit($start, $limit)->all("name"); if (count($list) === $max_size) { $max_size = NULL; } } else { $max_size = NULL; $list = []; foreach ($ids as $id) { $list[] = WORD(defaultDB(), intval($id)); } } return $list; }