$privileges) { if (!empty($privileges['auth_read'])) { $allowed_forum_ids[] = $forum_id; } } // end auth check // Function that requests the kredor.com service // parameters are: // - the latin text to be transliterated from // - the language code to be transliterated to ('bg' and 'ru' are the allowed values) // The function was taken from kredor.com and modified. function lat2cyr ($input_text, $service) { $transform = false; switch ($service) { case 'bg': $transform = 'lat2bg'; break; case 'ru': $transform = 'lat2ru'; break; default: break; } if (!$transform) { return false; } //URL-encode the text to be sent $data="Latin=" . urlencode($input_text); // Generate the request header $req_header = "POST http://". $transform .".kredor.com/scgi-bin/og.php?op=lat2bg&mode=a HTTP/1.0\n" . "Host: " . $transform . ".kredor.com\n" . "Content-Type: application/x-www-form-urlencoded\n" . "Content-Length: " . strlen($data) ."\n" . "Connection: close\n\n"; // Open the connection to the host $socket = fsockopen($transform . '.kredor.com', 80, &$errno, &$errstr); if (!$socket) { $result['errno'] = $errno; $result['errstr'] = $errstr; return $result; } //Submit data fputs($socket, $req_header); fputs($socket, $data); while (!feof($socket)) { $result .= fgets($socket, 128); } fclose($socket); //Strip HTTP header $result=substr($result, strpos($result, "\r\n\r\n") + 4); return $result; } // SQL query $sql = "SELECT u.user_sig, u.user_sig_bbcode_uid, pt.post_text, pt.bbcode_uid FROM " . POSTS_TABLE . " AS p, " . POSTS_TEXT_TABLE . " as pt, " . USERS_TABLE . " AS u WHERE p.forum_id IN (". implode(',',$allowed_forum_ids) .") AND p.poster_id = u.user_id AND pt.post_id = p.post_id AND p.post_id ='" . addslashes(@$_GET['p']) . "' "; $result = $db->sql_query($sql); if ($db->sql_numrows() != 1) { $post_text = $lang['Topic_post_not_exist']; $user_sig = ''; } else { $post = $db->sql_fetchrow(); // parse text $post_text = $post['post_text']; $post_text = bbencode_second_pass($post_text, $post['bbcode_uid']); $post_text = smilies_pass($post_text); $post_text = preg_replace("/$smilies_path/", $smilies_url, $post_text); $post_text = make_clickable($post_text); // parse user signature $user_sig = $post['user_sig']; $user_sig = bbencode_second_pass($user_sig, $post['user_sig_bbcode_uid']); $user_sig = smilies_pass($user_sig); $user_sig = preg_replace("/$smilies_path/", $smilies_url, $user_sig); $user_sig = make_clickable($user_sig); // request the transliteration service from Kredor.com $post_text = lat2cyr($post_text, TRANS_LANGUAGE); // append signature to the post $post_text .= (!empty($user_sig)) ? "
" . $user_sig : ""; } // set template file $template->set_filenames(array('body' => 'lat2cyr.tpl')); // assign template variables $template->assign_vars( array( 'SITENAME' => $board_config['sitename'], 'S_CONTENT_ENCODING' => $lang['ENCODING'], 'POST_TEXT' => nl2br($post_text), ) ); // process, parse and display $template->pparse('body'); ?>