Сохранение текста с тегами.
Необходимо сохранять в текстовый файл оформленный тегами текст. Но теги либо вообще не отображаются в текстовом файле, либо сохраняются некорректно.
Некорректное сохранение
Код:
<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>Текст</B></FONT></P>
Должно сохраняться в таком виде
Код:
<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>Текст</B></FONT></P>
Это можно как-то исправить?
Код AS1/AS2:
var my_lv:LoadVars = new LoadVars();
var my_ret:LoadVars = new LoadVars();
function save_txt_file(){
url="http://localhost/www/save_txt.php";
my_lv.save_txt = txt_output.text
my_lv.sendAndLoad(url, my_ret, "GET");
my_ret.onLoad = function(){
trace(my_lv.save_txt)
}
}
txt_input.onChanged = getIndexs;
var mouseListener:Object = new Object();
mouseListener.onMouseUp = getIndexs;
Mouse.addListener(mouseListener);
function getIndexs(){
if(Selection.getBeginIndex() != -1 && Selection.getEndIndex() != -1){
startIndex= Selection.getBeginIndex();
endIndex= Selection.getEndIndex();
}
txt_output.text=txt_input.htmlText
}
function checkFormat(val, startIndex, endIndex):Boolean{
var my_fmt:TextFormat = txt_input.getTextFormat(startIndex,endIndex);
return my_fmt[val];
}
function doChange(val):Void {
var stat:Boolean;
stat = (checkFormat(val, startIndex, endIndex)) ? false: true;
var format2_fmt:TextFormat = new TextFormat();
format2_fmt[val] = stat;
txt_input.setTextFormat(startIndex,endIndex,format2_fmt);
setSelection();
}
///button
var btn:MovieClip = this.createEmptyMovieClip("btn", 3);
btn.beginFill(0xFF0000);
btn.moveTo(10,10);
btn.lineTo(160,10);
btn.lineTo(160,40);
btn.lineTo(0,40);
btn.lineTo(0,10);
btn.endFill();
btn._y = 210;
btn._x = 0;
var my_fmt:TextFormat = new TextFormat();
var pole_txt:TextField = btn.createTextField("pole_txt", 4, 120, 15, 0, 0);
pole_txt.autoSize = true;
my_fmt.color = 0xFFFFFF;
my_fmt.size = 14;
pole_txt.html = true;
pole_txt.htmlText = '<b>Ж</b>';
pole_txt.setTextFormat(my_fmt);
btn.onPress = function(){
doChange("bold");
}
//
var btn_sav:MovieClip = this.createEmptyMovieClip("btn_sav", 5);
with(btn_sav){
beginFill(0xFF0000);
moveTo(10,10);
lineTo(160,10);
lineTo(160,40);
lineTo(0,40);
lineTo(0,10);
endFill();
_y = 250;
_x = 0;
}
var my_fmt_sav:TextFormat = new TextFormat();
var pole_txt:TextField = btn_sav.createTextField("pole_txt", 4, 35, 15, 0, 0);
pole_txt.autoSize = true;
my_fmt_sav.color = 0xFFFFFF;
my_fmt_sav.size = 14;
pole_txt.html = true;
pole_txt.htmlText = '<b>Сохранить</b>';
pole_txt.setTextFormat(my_fmt_sav);
btn_sav.onPress = save_txt_file
//
txt_input=this.createTextField("txt_input",2,10,10,300,200);
var my_fmt_input:TextFormat = new TextFormat();
txt_input.border=true
txt_input.type = "input"
txt_input.html = true;
txt_input.setTextFormat(my_fmt_input);
//
txt_output=this.createTextField("txt_output",6,320,10,200,200);
txt_output.wordWrap = true;
txt_output.border=true
//txt_output.html=true
Код:
<?php
session_start();
$result_name=strip_tags($_GET['save_txt']);
$newitems =$result_name;
$items = $newitems . file_get_contents('bold.txt');
file_put_contents('bold.txt', $items);
?>
|