show all sentences, including those, which snt_level=3 $show_all = false; if (!isset($main_verb_id)) { $ajax = true; $main_verb_id = -1; $verbparams = $_POST['verbparams']; if (!empty($_POST['id'])) { $main_verb_id = intval($_POST['id']); if (!isset($_POST['allsnt']) || $_POST['allsnt']==0) $snt_level = " AND snt_level<3"; } //$action = $_POST['action']; if ($main_verb_id == -1) { die(); } if (isset($_POST['trans'])) { $trans = intval($_POST['trans']); } include "vars.php"; $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;"); } else { if (isset($snt_id) && $snt_id > 0) { $snt_filter = " AND snt_id=$snt_id"; } elseif (!isset($_REQUEST['allsnt'])) { $snt_level = " AND snt_level<3"; } $verbparams = $_SERVER['QUERY_STRING']; $trans = $isPersScript ? 0 : 1; } $html = ''; $verbparams_array = explode("&", $verbparams); $newparams = array(); foreach ($verbparams_array as $param) { if (substr($param, 0, 3) !== 'snt' && substr($param, 0, 6) !== 'allsnt') $newparams[] = $param; $param_array = explode('=', $param); $verbparams_array[$param_array[0]] = $param_array[1]; } $verbparams = implode("&", $newparams); if (!isset($forceSnd)) { if (!isset($isSpoken)) { //$html .= print_r($verbparams_array, true); $r = mysql_query("SELECT * FROM $table WHERE id=$verbparams_array[id];"); if ($line = mysql_fetch_assoc($r)) { $isSpoken = ($line['style'] == 1 || $line['style'] == 2); } else { $isSpoken = false; } } if ($isSpoken) { $forceSnd = (isset($_SESSION['spsound'])) ? $_SESSION['spsound'] : 1; } else { $forceSnd = (isset($_SESSION['wrsound'])) ? $_SESSION['wrsound'] : 0; } } if ($main_verb_id) { $rsnt = mysql_query(" SELECT * FROM pvc_sentence s INNER JOIN pvc_verb_sentence vs ON (vs_sid=snt_id AND vs_vid=$main_verb_id) LEFT JOIN pvc_users ON snt_uid=u_id WHERE snt_new=0 $snt_filter $snt_level ORDER BY snt_level, snt_id DESC"); } $i = 0; $formats = array('mp3'); //, 'm4a' while ($sentence = mysql_fetch_assoc($rsnt)) { $i++; $html .= "
"; if ($main_verb_id) { if ($snt_filter == '') { $html .= "
[ permalink to this sentence ]
"; } else { if ($sentence['snt_level']==3) { $show_all = true; } else { $snt_level = " AND snt_level<3"; } } } $html .= "

1 ? " style='margin-top: 10px'" : "") . ">" . AddTags($sentence['snt_text'], isset($sentence['vs_vpos_pers']) ? $sentence['vs_vpos_pers'] : ""); if ($forceSnd) { foreach ($formats as $ext) { $mp3file = 'snt/' . $sentence['snt_id'] . '.' . $ext; if (file_exists($mp3file)) { if ($ajax) { $html .= " "; } else { $html .= " "; } break; } } } if (!empty($sentence['snt_transcr'])) { $html .= "

" . AddTags(htmlspecialchars_decode($sentence['snt_transcr'], ENT_QUOTES), isset($sentence['vs_vpos_trans']) ? $sentence['vs_vpos_trans'] : ""); } if (!empty($sentence['snt_translation'])) { $html .= "

{$sentence['snt_translation']}"; } $contributor = $sentence['u_name']; if ($sentence['snt_byadmin'] == 1) { $contributor = "webmaster for $contributor"; } if (!empty($contributor)) { if ($sentence['u_showemail'] == 1) { $mailhide_pubkey = '01hhDfl0kVJ7zRlhjCMmNVfA=='; $mailhide_privkey = 'A69AB03DB01FE736559688AB3C8CB37D'; $contributor = "$contributor"; } $html .= " (Submitted by $contributor"; if ($sentence['snt_date'] !== '0000-00-00') { $html .= " on " . date("M j, Y", strtotime($sentence['snt_date'])); } $html .= ")"; } $html .= "

"; if ($sentence['snt_style'] == 1) { $html .= "This example is in Spoken style. "; } $html .= $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"; } if (!empty($source)) $html .= " (" . $source . ")"; $rov = mysql_query(" SELECT * FROM $table v INNER JOIN pvc_verb_sentence vs ON (id=vs_vid AND vs_sid=$sentence[snt_id] AND vs_vid<>$main_verb_id)"); if (mysql_num_rows($rov) > 0) { $html .= " See " . ($main_verb_id ? "other " : "") . "verbs of this sentence: "; $links = array(); while ($otherverb = mysql_fetch_assoc($rov)) { $inf = $trans ? $otherverb['trans_inf'] : $otherverb['pers_inf']; $linkov = "$inf"; if ($trans == 0) { $linkov = "$linkov"; } $links[] = $linkov; } $html .= implode(($trans == 0 ? "، " : ", "), $links); } $html .= "

"; } if (!empty($snt_filter)) { $r = mysql_query(" SELECT * FROM pvc_sentence s INNER JOIN pvc_verb_sentence vs ON (vs_sid=snt_id AND vs_vid=$main_verb_id) LEFT JOIN pvc_users ON snt_uid=u_id WHERE snt_new=0 $snt_level"); $snt_count = mysql_num_rows($r); if ($snt_count > 1) { $html .= "
Show all $snt_count sentences
"; } } print $html; function AddTags($text, $positions) { $offset = 0; $tagged_text = $text; if (!empty($positions)) { $positions = explode(",", $positions); if (count($positions) % 2 == 0) { SortPositions($positions); for ($i = 0; $i" . mb_substr($tagged_text, $positions[$i] + $offset, $positions[$i + 1] - $positions[$i]) . "" . mb_substr($tagged_text, $positions[$i + 1] + $offset); $offset += strlen(""); } } } } return $tagged_text; } function SortPositions(&$positions) { for ($j = 0; $j $positions[$i + 2]) { $t1 = $positions[$i]; $t2 = $positions[$i + 1]; $positions[$i] = $positions[$i + 2]; $positions[$i + 1] = $positions[$i + 3]; $positions[$i + 2] = $t1; $positions[$i + 3] = $t2; } } } }