\n"; else print "\n"; $u_login_logout = 'login.' . $phpEx . '?logout=true&sid=' . $userdata['session_id']; $l_login_logout = 'Log out' . ' [ ' . $userdata['username'] . ' ]'; print '

' . $l_login_logout . '' . $l_login_logout . '' . "\n"; include "vars.php"; $footer = '



Copyright (c) Artem Lukanin

'; $link = mysql_connect("localhost", $login, $pass) or die("Could not connect: " . mysql_error()); mysql_select_db($db) or die("Could not select database"); mysql_query("SET NAMES utf8;"); $topics = array(); $meanings = array(array('m_text' => '', 'm_tags' => '', 'm_transitive' => '', 'synset' => null)); if (empty($_POST['B1'])) { if ($_GET['opt'] == 'edit') { print "

Edit Persian Verb

"; $verbid = intval($_GET['id']); $r = mysql_query("SELECT * FROM $table WHERE id=$verbid;"); $verb = mysql_fetch_array($r, MYSQL_ASSOC); $pers_inf = $verb['pers_inf']; $pers_stem = $verb['pers_presstem']; $trans_inf = $verb['trans_inf']; $trans_stem = $verb['trans_presstem']; $dialect = $verb['dialect']; if ($dialect == 'Tehran' || $dialect == 'Dari/Kabul' || $dialect == 'Tajik') $other_dial = ''; else $other_dial = $dialect; $tags = $verb['tags']; $transitive = $verb['transitive']; $changeofstate = $verb['changeofstate']; $noMiInPrsIndicative = $verb['nomi-']; $noBeInSubjunctive = $verb['nobeinsubj']; $hasSound = $verb['hassnd']; $hasSoundTest = $verb['hassndtest']; $style = $verb['style']; $style_id = $verb['style_id']; $comp_id = $verb['comp_id']; $comp_type = $verb['comp_type']; $comp_dtype = $verb['comp_dtype']; $comp_sem = $verb['comp_sem']; $testtype = $verb['testtype']; $level = $verb['level']; $button_name = 'Update'; $translation = $verb['translation']; $r = mysql_query(" SELECT m.*, GROUP_CONCAT(CAST(sn_synset AS CHAR(5))) synset FROM pvc_meanings m LEFT JOIN pvc_synonyms s ON m_id=sn_meaning WHERE m_vid=$verbid GROUP BY m_id ORDER BY m_order"); if (mysql_num_rows($r) > 0) { $meanings = array(); while ($row = mysql_fetch_array($r)) { $meanings[] = $row; } } $r = mysql_query("SELECT * FROM pvc_old_synonyms WHERE verb1=$verbid OR verb2=$verbid"); $synonyms = array(); while ($row = mysql_fetch_array($r)) { if ($row[0] == $verbid) { $synonyms[] = $row[1]; } else { $synonyms[] = $row[0]; } } $synonyms = implode(",", $synonyms); if (!empty($synonyms)) { $r = mysql_query("SELECT * FROM pvc_verbs WHERE id IN ($synonyms) ORDER BY trans_inf"); $synarr = ""; } if ($style_id != -1) { $r = mysql_query("SELECT * FROM pvc_verbs WHERE id=$style_id"); $wrsparr = ""; } if ($comp_id != -1) { $r = mysql_query("SELECT * FROM pvc_verbs WHERE id=$comp_id"); $comparr = ""; } $r = mysql_query("SELECT * FROM pvc_verb_topics WHERE verb_id=$verbid"); while ($topic = mysql_fetch_assoc($r)) { $topics[] = $topic['topic_id']; } include 'form.php'; } elseif ($_GET['opt'] == 'add') { print "

Add Persian Verb

"; $dialect = 'Tehran'; $other_dial = ''; $tags = ''; $transitive = 0; $testtype = -1; $comp_id = -1; $comp_type = 0; $comp_dtype = 0; $comp_sem = 0; $changeofstate = 0; $noMiInPrsIndicative = 0; $noBeInSubjunctive = 0; $hasSound = 0; $hasSoundTest = 0; $style = 0; $button_name = 'Add'; $verbid = ""; $synonyms = ""; include 'form.php'; } else { if ($_GET['opt'] == 'del') { $verbid = $_GET['id']; mysql_query("DELETE FROM $table WHERE id=$verbid;"); mysql_query("DELETE FROM pvc_old_synonyms WHERE verb1=$verbid OR verb2=$verbid;"); mysql_query("DELETE FROM pvc_verb_topics WHERE verb_id=$verbid;"); mysql_query("DELETE FROM pvc_meanings WHERE m_vid=$verbid;"); } $where = ''; $all = ''; if ($_GET['all'] == 1) { $all = '&all=1'; print "

Only Unreviewed | All Verbs | All Verbs with Sentences | Manage Synsets

"; $r = mysql_query("SELECT * FROM $table ORDER BY pers_inf;"); if (!$r) { exit("

The list of verbs does not exist.

\n"); } $total = mysql_num_rows($r); } elseif ($_GET['all'] == 'sent') { $all = '&all=sent'; print "

Only Unreviewed | All Verbs | All Verbs with Sentences | Manage Synsets

"; $r = mysql_query("SELECT p.*, COUNT(s.vs_sid) scount FROM $table p LEFT JOIN pvc_verb_sentence s ON p.id=vs_vid GROUP BY p.id HAVING scount>0 ORDER BY pers_inf;"); if (!$r) { exit("

The list of verbs does not exist.

\n"); } $total = mysql_num_rows($r); } else { print "

Only Unreviewed | All Verbs | All Verbs with Sentences | Manage Synsets

"; $where = 'WHERE isnew=1'; $r = mysql_query("SELECT * FROM $table $where ORDER BY pers_inf;"); if (!$r) { exit("

The list of verbs does not exist.

\n"); } $total = mysql_num_rows($r); if ($total == 0) { print "There are no unreviewed verbs."; } } if ($p !== 'all') { $p = intval($p); if ($_GET['all'] == 'sent') { $r = mysql_query("SELECT p.*, COUNT(s.vs_sid) scount FROM $table p LEFT JOIN pvc_verb_sentence s ON p.id=vs_vid GROUP BY p.id HAVING scount>0 ORDER BY pers_inf LIMIT " . ($p * 100) . ",100"); } else { $r = mysql_query("SELECT * FROM $table $where ORDER BY pers_inf LIMIT " . ($p * 100) . ",100"); } } ?>

Add a Persian Verb

100) { $pages .= "

Pages: "; for($i = 0; $i < ceil($total / 100); $i++) { $plink = $i + 1; if ($p !== $i) { $plink = "$plink"; } $pages .= " $plink"; } $pages .= " | All

"; } print $pages; if ($total > 0) { ?> {$other_style['pers_inf']}"; } } } $pvcmode = ($verb['style'] == 0 || $verb['style'] == 3 ? "" : "&spoken"); print "\n"; } print "
N
e
w
Persian Transcription English Translation Synonyms Tran
sitive
Change of state no be-
no mi-
Lamb
ton / Dabir-Moghad
dam
Style Test Level Has Snd
$new{$verb['pers_inf']}
{$verb['pers_presstem']}"; $rsnt = mysql_query("SELECT s.* FROM pvc_verb_sentence vs INNER JOIN pvc_sentence s ON (snt_id=vs_sid AND vs_vid=$verb[id])"); $snt_count = mysql_num_rows($rsnt); if ($snt_count > 0) { print "

+$snt_count ]

"; } print "
{$verb['trans_inf']}
{$verb['trans_presstem']}
"; if (!empty($verb['translation'])) { $trans_ar = explode(",", $verb['translation']); $tags_ar = explode(",", $tags); $prev_meaning_tags = ''; for($i = 0; $i < count($trans_ar); $i++) { if (isset($tags_ar[$i]) && trim($tags_ar[$i]) != '') { $tags_ar[$i] = trim(preg_replace("' +'", " ", $tags_ar[$i])); $tr_tags_ar = explode(" ", $tags_ar[$i]); for($k = 0; $k < count($tr_tags_ar); $k++) { $tr_tags_ar[$k] = trim($tr_tags_ar[$k]); } $meaning_tags = implode(" ", $tr_tags_ar); $new_value = ''; if ($prev_meaning_tags != $meaning_tags || empty($meaning_tags)) { if ($i > 0) { $trans_ar[$i - 1] .= ';'; } for($k = 0; $k < count($tr_tags_ar); $k++) { $abbr = $tr_tags_ar[$k]; $j = array_search($abbr, $a_tags); if ($j !== false) { $title = $a_titles[$j]; } else { $title = ''; } if (!empty($new_value)) $new_value .= ' '; $new_value .= "$abbr"; } } if (!empty($new_value)) { $trans_ar[$i] = $new_value . " " . trim($trans_ar[$i]); } } else { $meaning_tags = ''; } $trans_ar[$i] = trim($trans_ar[$i]); $prev_meaning_tags = $meaning_tags; } $tagged_translation = implode(", ", $trans_ar); $tagged_translation = str_replace(';,', ';', $tagged_translation); if (substr($tagged_translation, -1) == ';') { $tagged_translation = substr($tagged_translation, 0, -1); } print $tagged_translation; } $topics_text = ''; $rt = mysql_query("SELECT * FROM pvc_verb_topics vt LEFT JOIN pvc_topics t ON topic_id=t_id WHERE verb_id=$verb[id] ORDER BY t_name;"); while ($next_topic = mysql_fetch_assoc($rt)) { if (!empty($topics_text)) { $topics_text .= ', '; } $topics_text .= $next_topic['t_name']; } if (!empty($topics_text)) { print "
$topics_text"; } print "
"; $rs = mysql_query("SELECT * FROM pvc_old_synonyms WHERE verb1=$verb[id] OR verb2=$verb[id]"); $synonyms = array(); while ($rowsyn = mysql_fetch_array($rs)) { if ($rowsyn[0] == $verb[id]) { $synonyms[] = $rowsyn[1]; } else { $synonyms[] = $rowsyn[0]; } } $synonyms = implode(",", $synonyms); if (!empty($synonyms)) { $rs = mysql_query("SELECT * FROM pvc_verbs WHERE id IN ($synonyms) ORDER BY trans_inf"); if (mysql_num_rows($rs) > 0) { $j = 0; while ($rowsyn = mysql_fetch_assoc($rs)) { if ($j > 0) print "
"; print "$rowsyn[pers_inf]"; $j++; } } else print " "; } $c_type = $lambton[$verb['comp_type']] . " / " . $dabir[$verb['comp_dtype']]; if ($c_type == " / ") $c_type = ""; print "
$transitive$changeofstate$noBeInSubjunctive" . $c_type . "$style " . ($verb['testtype'] != -1 ? $verb['testtype'] : " ") . " "; if ($verb['level'] == 1) print "basic"; elseif ($verb['level'] == 2) print "advanced"; print "$hasSound edit delete
\n"; print $pages; } //======================================================== // New sentences if (empty($all)) { $r = mysql_query(" SELECT * FROM pvc_sentence s INNER JOIN pvc_verb_sentence vs ON vs_sid=snt_id LEFT JOIN pvc_verbs ON id=vs_vid LEFT JOIN pvc_users ON u_id=snt_uid WHERE snt_new<>0"); if (mysql_num_rows($r) > 0) { print "

New Sentences

"; ?> \n"; } } } exit($footer); } } else { $pers_inf = $_POST['pers_inf']; $pers_stem = $_POST['pers_stem']; $trans_inf = str_replace("aa", "ā", $_POST['trans_inf']); $trans_stem = str_replace("aa", "ā", $_POST['trans_stem']); $translation = $_POST['transl']; $m_transitive = $_POST['transit']; $testtype = intval($_POST['testtype']); $level = intval($_POST['level']); $verbid = $_POST['verbid']; if (empty($verbid)) { $button_name = 'Add'; } else { $button_name = 'Update'; } if (empty($pers_inf)) { print "WARNING: Enter the infinitive in Persian script!\n"; } elseif (empty($pers_stem)) { print "WARNING: Enter the Present Stem in Persian script!\n"; } elseif (empty($trans_inf)) { print "WARNING: Enter the transcription of the infinitive!\n"; } elseif (empty($trans_stem)) { print "WARNING: Enter the transcription of the Present Stem!\n"; } else { if (empty($_POST['other_dial'])) { $dialect = $_POST['dialect']; if ($dialect == 'Default standard Tehran') $dialect = 'Tehran'; } else $dialect = $_POST['other_dial']; $tags = $_POST['tags']; $ssynonyms = $_POST['ssynonyms']; // remove empty meanings $mcount = count($translation); for($i = 0; $i < $mcount; $i++) { if (trim($translation[$i]) == '') { unset($translation[$i]); unset($tags[$i]); unset($m_transitive[$i]); unset($ssynonyms[$i]); } } $translation = array_merge($translation, array()); $tags = array_merge($tags, array()); $m_transitive = array_merge($m_transitive, array()); $ssynonyms = array_merge($ssynonyms, array()); $transitive = $_POST['transitive']; $changeofstate = intval($_POST['changeofstate']); $noMiInPrsIndicative = intval($_POST['nomi']); $noBeInSubjunctive = intval($_POST['nobeinsubj']); $hasSound = isset($_POST['hassnd']) ? 1 : 0; $hasSoundTest = isset($_POST['hassndtest']) ? 1 : 0; $synonyms = explode(",", $_POST['synonyms']); $style = $_POST['style']; $style_id = $_POST['style_id']; if ($style_id == "") $style_id = -1; $comp_id = $_POST['comp_id']; $comp_type = intval($_POST['comp_type']); $comp_dtype = intval($_POST['comp_dtype']); $comp_sem = intval($_POST['comp_sem']); if ($comp_id == "") $comp_id = -1; foreach ($_POST as $key => $value) { $t_id = intval(substr($key, 2)); if (substr($key, 0, 2) == 't_' && $t_id > 0) { $topics[] = $t_id; } } if (empty($verbid)) { $r = mysql_query("INSERT INTO $table (pers_inf, pers_presstem, trans_inf, trans_presstem, isnew, dialect, transitive, changeofstate, nobeinsubj, `nomi-`, hassnd, hassndtest, style, style_id, translation, tags, testtype, level, comp_id, comp_type, comp_dtype, comp_sem) VALUES(\"" . mysql_real_escape_string($pers_inf) . "\", \"" . mysql_real_escape_string($pers_stem) . "\", \"" . mysql_real_escape_string($trans_inf) . "\", \"" . mysql_real_escape_string($trans_stem) . "\", 0, \"" . mysql_real_escape_string($dialect) . "\", $transitive, $changeofstate, $noBeInSubjunctive, $noMiInPrsIndicative, $hasSound, $hasSoundTest, $style, $style_id, \"" . mysql_real_escape_string(implode(', ', $translation)) . "\", \"" . mysql_real_escape_string(implode(',', $tags)) . "\", $testtype, $level, $comp_id, $comp_type, $comp_dtype, $comp_sem);"); $verbid = mysql_insert_id(); if (!$r) { print "

Could not add this verb.

\n"; } else { foreach ($synonyms as $synonym) { $r = mysql_query("INSERT INTO pvc_old_synonyms (verb1, verb2) VALUES ($verbid, $synonym)"); } foreach ($topics as $t_id) { $r = mysql_query("INSERT INTO pvc_verb_topics (verb_id, topic_id) VALUES ($verbid, $t_id)"); } // if ($style_id>-1) { // $r = mysql_query("UPDATE $table SET style_id=$verbid WHERE id=$style_id"); // } print "

The verb was successfully added. See its conjugation: $trans_inf

"; } } else { $r = mysql_query("UPDATE $table SET pers_inf='" . mysql_real_escape_string($pers_inf) . "', pers_presstem='" . mysql_real_escape_string($pers_stem) . "', trans_inf='" . mysql_real_escape_string($trans_inf) . "', trans_presstem='" . mysql_real_escape_string($trans_stem) . "', translation='" . mysql_real_escape_string(implode(', ', $translation)) . "', tags='" . mysql_real_escape_string(implode(',', $tags)) . "', isnew=0, dialect='" . addslashes($dialect) . "', transitive=$transitive, changeofstate=$changeofstate, nobeinsubj=$noBeInSubjunctive, `nomi-`=$noMiInPrsIndicative, hassnd=$hasSound, hassndtest=$hasSoundTest, style=$style, style_id=$style_id, testtype=$testtype, level=$level, comp_id=$comp_id, comp_type=$comp_type, comp_dtype=$comp_dtype, comp_sem=$comp_sem WHERE id=$verbid;"); if (!$r) { print "

Could not update this verb: " . mysql_error() . ".

\n"; } else { $r = mysql_query("DELETE FROM pvc_old_synonyms WHERE verb1=$verbid OR verb2=$verbid"); foreach ($synonyms as $synonym) { $r = mysql_query("INSERT INTO pvc_old_synonyms (verb1, verb2) VALUES ($verbid, $synonym)"); } $r = mysql_query("DELETE FROM pvc_verb_topics WHERE verb_id=$verbid"); foreach ($topics as $t_id) { $r = mysql_query("INSERT INTO pvc_verb_topics (verb_id, topic_id) VALUES ($verbid, $t_id)"); } // if ($style_id>-1) { // $r = mysql_query("UPDATE $table SET style_id=$verbid WHERE id=$style_id"); // } print "

The verb was successfully updated. See its conjugation: $trans_inf

"; } } // Delete all verb meanings from synsets mysql_query("DELETE s.* FROM pvc_meanings m, pvc_synonyms s WHERE m_vid=$verbid AND m_id=sn_meaning"); // Delete all verb meanings mysql_query("DELETE FROM pvc_meanings WHERE m_vid=$verbid;"); $cnt = 1; for($i = 0; $i < count($translation); $i++) { if (trim($translation[$i] . $tags[$i]) != '') { // ... and add the new ones (may be the same) mysql_query("INSERT INTO pvc_meanings (m_vid, m_text, m_tags, m_transitive, m_order) VALUES ($verbid, \"" . mysql_real_escape_string($translation[$i]) . "\", \"" . mysql_real_escape_string($tags[$i]) . "\", " . $m_transitive[$i] . ", $cnt);"); $m_id = mysql_insert_id(); // if there are synsets chosen for this meaning if (!empty($ssynonyms[$i])) { $ss = explode(';', $ssynonyms[$i]); foreach ($ss as $synset) { $synset = explode(':', $synset); $synset[1] = explode(',', $synset[1]); // ... truncate this synset mysql_query("DELETE FROM pvc_synonyms WHERE sn_synset=" . $synset[0]); // ... and add them in the new order $syncnt = 1; foreach ($synset[1] as $synonym) { if ($synonym != '') { // the current meaning if ($synonym == 0) $synonym = $m_id; mysql_query("INSERT INTO pvc_synonyms (sn_synset, sn_meaning, sn_order) VALUES (" . $synset[0] . ", $synonym, $syncnt);"); $syncnt++; } } } } $cnt++; } } exit("See: Only Unreviewed | All Verbs"); } $dialect = $_POST['dialect']; $other_dial = $_POST['other_dial']; $tags = $_POST['tags']; $transitive = intval($_POST['transitive']); $changeofstate = intval($_POST['changeofstate']); $noMiInPrsIndicative = intval($_POST['nomi']); $noBeInSubjunctive = intval($_POST['nobeinsubj']); $style = $_POST['style']; $style_id = $_POST['style_id']; $comp_id = $_POST['comp_id']; $comp_type = intval($_POST['comp_type']); $comp_dtype = intval($_POST['comp_dtype']); $comp_sem = intval($_POST['comp_sem']); $button_name = 'Add'; $synonyms = ""; include 'form.php'; } } else { if ($userdata['session_logged_in']) redirect("../pvc/login." . $phpEx . '?logout=true&sid=' . $userdata['session_id'], true); else redirect("../pvc/login.$phpEx", true); } ?>
Verb Sentence Source Contributor
{$sentence['pers_inf']}

{$sentence['snt_text']}"; if ($sentence['snt_new'] == 2) { print " postponed"; } if (!empty($sentence['snt_transcr'])) { print "

{$sentence['snt_transcr']}"; } if (!empty($sentence['snt_translation'])) { print "

{$sentence['snt_translation']}"; } if (!empty($sentence['snt_note'])) { print "

{$sentence['snt_note']}"; } $source = array(); if (!empty($sentence['snt_source'])) { $source[] = $sentence['snt_source']; } if (!empty($sentence['snt_author'])) { $source[] = "$sentence[snt_author]"; } if ($sentence['snt_year'] != 0) { $source[] = "$sentence[snt_year]"; } $source = implode(", ", $source); if (!empty($sentence['snt_url'])) { if (empty($source)) $source = 'source'; $source = "$source"; } print "

" . $source . " "; $contributor = $sentence['u_name']; if ($sentence['snt_byadmin'] == 1) { $contributor = "webmaster for $contributor"; } if (!empty($sentence['u_email'])) { $contributor = "$contributor"; } print $contributor . ($sentence['snt_date'] !== '0000-00-00' ? "
" . date("M j, Y", strtotime($sentence['snt_date'])) : "") . "
edit delete