| Суть скрипта :
Вы вводите в формы всякие слова, а вам в textarea выводит их в преобразованном виде без перезагрузки страницы....
Я долго уже мучаюсь ;-)
Сделал... Но в фф все хорошо работает, в опере не хочет =\
index.php
<?php
ini_set("display_errors","0");
$color_title = "#d0d0b8";
$bcol = "[color=#FFFF99]";
$ecol = "[/color][color=#ffffff]";
$fcol = "[/color]";
function encode($str, $type)
{
static $conv='';
if (!is_array ( $conv ))
{
$conv=array ();
for($x=128; $x <=143; $x++ )
{
$conv['utf'][] = chr(209).chr($x);
$conv['win'][] = chr($x+112);
}
for( $x=144; $x <=191; $x++ )
{
$conv['utf'][] = chr(208).chr($x);
$conv['win'][] = chr($x+48);
}
$conv['utf'][] = chr(208).chr(129);
$conv['win'][] = chr(168);
$conv['utf'][] = chr(209).chr(145);
$conv['win'][] = chr(184);
}
if( $type=='w' )
return str_replace ( $conv['utf'], $conv['win'], $str );
elseif( $type=='u' )
return str_replace ( $conv['win'], $conv['utf'], $str );
else
return $str;
}
if($_POST['end'])
{
header ("Content-Type: text/xml; charset=windows-1251");
print ("<?xml version=\"1.0\" standalone=\"yes\"?>\r\n");
print ("<responce>\r\n");
print ("<system>\r\n");
if(!empty($_POST['title']))
echo "[size=5][color=".$color_title."]".encode($_POST['title'],w);
if(!empty($_POST['eng_title']))
echo "/".encode($_POST['eng_title'],w)."[/color][/size]\n";
else echo "[/color][/size][/b][/center]\n";
if(!empty($_POST['img']))
echo "[film=".encode($_POST['img'],w)."]\n\n";
if(!empty($_POST['year']))
echo $bcol."Год выхода: ".$ecol.encode($_POST['year'],w).$fcol."\n";
if(!empty($_POST['genre']))
echo $bcol."Жанр: ".$ecol.encode($_POST['genre'],w).$fcol."\n";
if(!empty($_POST['author']))
echo $bcol."Режиссер: ".$ecol.encode($_POST['author'],w).$fcol."\n";
if(!empty($_POST['actors']))
echo $bcol."В ролях: ".$ecol.encode($_POST['actors'],w).$fcol."\n";
if(!empty($_POST['about']))
echo $bcol."О фильме: ".$ecol.encode($_POST['about'],w).$fcol."\n";
if(!empty($_POST['lang']))
echo $bcol."Перевод: ".$ecol.encode($_POST['lang'],w).$fcol."\n";
if(!empty($_POST['manufacturers']))
echo $bcol."Производство: ".$ecol.encode($_POST['manufacturers'],w).$fcol."\n";
if(!empty($_POST['duration']))
echo $bcol."Продолжительность: ".$ecol.encode($_POST['duration'],w).$fcol."\n";
if(!empty($_POST['quality']))
echo $bcol."Качество: ".$ecol.encode($_POST['quality'],w).$fcol."\n";
if(!empty($_POST['size']))
echo $bcol."Размер: ".$ecol.encode($_POST['size'],w).$fcol."\n";
if(!empty($_POST['link']))
echo $bcol."Скачать: [/color][/b][url=".encode($_POST['link'],w)."][color=#ffffff]".encode($_POST['title'],w)."[/color][/url]\n";
if(!empty($_POST['pass']))
echo $bcol."Пароль: [/color][/b][color=red]".encode($_POST['pass'],w)."[/color]\n";
echo "[/film]";
print ("</system>\r\n");
print ("</responce>\r\n");
exit;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<?php include('xek.js'); ?>
<style type="text/css">
body
{
background: #161616 url(hex/images/misc/background.gif);
color: #A6A6A6;
font: 11px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
margin: 0px 10px 0px 10px;
padding: 0px;
}
a:link, body_alink
{
color: #D0D0D0;
}
a:visited, body_avisited
{
color: #D0D0D0;
}
a:hover, a:active, body_ahover
{
color: #D0D0D0;
}
td, th, p, li
{
font: 11px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
.tborder
{
background: #161616;
color: #A6A6A6;
font-size: 11px;
border-left: 1px solid #161616;
border-top: 1px solid #161616;
border-right: 0px solid #161616;
border-bottom: 1px solid #161616;
}
td.inlinemod
{
background: #353535;
color: #BDBDBD;
font-size: 11px;
border-left: 1px solid #4C4C4C;
border-top: 1px solid #4C4C4C;
border-bottom: 1px solid #181818;
border-right: 1px solid #181818;
padding: 3px;
}
td.inlinemod a:link, td.inlinemod_alink
{
color: #BDBDBD;
}
td.inlinemod a:visited, td.inlinemod_avisited
{
color: #BDBDBD;
}
td.inlinemod a:hover, td.inlinemod a:active, td.inlinemod_ahover
{
color: #FFFFFF;
}
textarea, .bginput
{
background: #1E1E1E;
color: #FFFFFF;
font: 11px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
border: 1px solid #4A4A4A;
}
.button
{
background: #5E5E5E;
color: #FFFFFF;
font: 11px verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
border: 2px solid #242424;
}
option, optgroup
{
font-size: 11px;
font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
}
html
{
scrollbar-face-color: #292929;
scrollbar-shadow-color: #202020;
scrollbar-highlight-color: #333333;
scrollbar-3dlight-color: #202020;
scrollbar-darkshadow-color: #171717;
scrollbar-track-color: #171717;
scrollbar-arrow-color: #999999;
}
</style>
</head>
<body>
<table width="300" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><font color="#FFFFFF">Название :</font></td>
<td align="right"><input type="text" value="" id="title" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">English Title :</font></td>
<td align="right"><input type="text" value="" id="eng_title" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Картинка(ссылка) :</font></td>
<td align="right"><input type="text" value="" id="img" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Год выхода :</font></td>
<td align="right"><input type="text" value="" id="year" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Режиссер:</font></td>
<td align="right"><input type="text" value="" id="author" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">В ролях:</font></td>
<td align="right"><input type="text" value="" id="actors" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Жанр :</font></td>
<td align="right">
<select id="genre" style="width: 150;height:20">
<option selected></option>
<option value="Комедия">Комедия</option>
<option value="Боевик">Боевик</option>
<option value="Триллер">Триллер</option>
<option value="Ужасы">Ужасы</option>
<option value="Фантастика">Фантастика</option>
<option value="Приключения">Приключения</option>
<option value="Мультфильм">Мультфильм</option>
<option value="Драма">Драма</option>
<option value="Эротика">Эротика</option>
<option value="Документальное кино">Документальное кино</option>
</select></td>
</tr>
<tr>
<td valign="top"><font color="#FFFFFF">О фильме :</font></td>
<td align="right"><textarea type="text" value="" id="about" rows="5" cols="20"></textarea></td>
</tr>
<tr>
<td><font color="#FFFFFF">Перевод:</font></td>
<td align="right"><input type="text" value="" id="lang" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Производство :</font></td>
<td align="right"><input type="text" value="" id="manufacturers" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Продолжительность :</font></td>
<td align="right"><input type="text" value="" id="duration" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Качество :</font></td>
<td align="right"><input type="text" value="" id="quality" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Размер :</font></td>
<td align="right"><input type="text" value="" id="size" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Скачать(ссылка) :</font></td>
<td align="right"><input type="text" value="" id="link" style="width: 150;height:20" /></td>
</tr>
<tr>
<td><font color="#FFFFFF">Пароль:</font></td>
<td align="right"><input type="text" value="" id="pass" style="width: 150;height:20" /></td>
</tr>
</table>
<br/><span style="color:red">Перед нажатием на кнопку, убедитесь, правильно ли вы заполнили все поля!</span><br/>
<input type="button" class=button" id="end" value="Продолжить" onclick="command()"/>
<pre><textarea type="text" value="" id="system" rows="5" cols="50"></textarea></pre>
<input type="button" class=button" value="Готово" onclick="send()"/>
<table width="300" border="0" cellpadding="0" cellspacing="0"><tr>
<td colspan="4" align="center"><input type="button" class="button" value="Закрыть окно" onclick="self.close()" /></td>
</tr></table>
</body>
</html>
|
xek.js
<script type="text/javascript">
var xmlhttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject(){
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e){
try{
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
}
catch(e){
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){}
}
}
if(!xmlhttp){
alert("Не удалось создать объект XMLHttpRequest");
}
return xmlhttp;
}
function createRequestProcess(pdata,type)
{
xmlhttp=createXmlHttpRequestObject();
if (xmlhttp)
{
try
{
xmlhttp.open("POST","<?=$_SERVER['SCRIPT_NAME'];?>",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
xmlhttp.setRequestHeader("Content-length", pdata.length);
xmlhttp.send(pdata);
xmlhttp.onreadystatechange = handleRequestStateChange;
}
catch (e) {alert('error : '+e.toString());}
}
}
function handleRequestStateChange()
{
if (xmlhttp.readyState == 4)
{
if (xmlhttp.status == 200)
{
try { ReadResponce(); }
catch (e) {}
} else {
if (xmlhttp.status == 404){
alert("Request URL does not exist");
} else {
alert("Error: status code is " + xmlhttp.status);
}
}
}
}
function ReadResponce()
{
xmlresponce = xmlhttp.responseXML;
xmldocelement = xmlresponce.documentElement;
xmldocanswer = xmldocelement.getElementsByTagName("system").item(0).firstChild.data;
myDiv = document.getElementById("system");
myDiv.innerHTML = xmldocanswer;
}
function command()
{
title = document.getElementById('title').value;
eng_title = document.getElementById('eng_title').value;
img = document.getElementById('img').value;
year = document.getElementById('year').value;
genre = document.getElementById('genre').value;
actors = document.getElementById('actors').value;
author = document.getElementById('author').value;
about = document.getElementById('about').value;
lang = document.getElementById('lang').value;
manufacturers = document.getElementById('manufacturers').value;
duration = document.getElementById('duration').value;
quality = document.getElementById('quality').value;
size = document.getElementById('size').value;
link = document.getElementById('link').value;
pass = document.getElementById('pass').value;
end = document.getElementById('end').value;
fdata = "title="+title+"&eng_title="+eng_title+"&img="+img+"&year="+year+"&genre="+genre+"&author="+author+"&actors="+actors+"&about="+about+"&lang="+lang+"&manufacturers="+manufacturers+"&duration="+duration+"&quality="+quality+"&size="+size+"&link="+link+"&pass="+pass+"&end="+end;
createRequestProcess(fdata);
}
function send()
{
window.opener.document.forms['vbform'].elements['vB_Editor_001_textarea'].value = document.getElementById('system').value;
}
</script>
|
| |