<?php
header('Content-type: text/html; charset=utf-8');
// The following variables values must reflect your installation needs.
$aspell_prog = '"C:\Program Files\Aspell\bin\aspell.exe"'; // by FredCK (for Windows)
//$aspell_prog = 'aspell'; // by FredCK (for Linux)
$lang = 'en_US';
$aspell_opts = "-a --lang=$lang --encoding=utf-8 -H --rem-sgml-check=alt"; // by FredCK
$tempfiledir = "./";
$spellercss = '../spellerStyle.css'; // by FredCK
$word_win_src = '../wordWindow.js'; // by FredCK
$textinputs = $_POST['textinputs']; # array
$input_separator = "A";
# set the JavaScript variable to the submitted text.
# textinputs is an array, each element corresponding to the (url-encoded)
# value of the text control submitted for spell-checking
function print_textinputs_var() {
global $textinputs;
foreach( $textinputs as $key=>$val ) {
# $val = str_replace( "'", "%27", $val );
echo "textinputs[$key] = decodeURIComponent(\"" . $val . "\");\n";
}
}
# make declarations for the text input index
function print_textindex_decl( $text_input_idx ) {
echo "words[$text_input_idx] = [];\n";
echo "suggs[$text_input_idx] = [];\n";
}
# set an element of the JavaScript 'words' array to a misspelled word
function print_words_elem( $word, $index, $text_input_idx ) {
echo "words[$text_input_idx][$index] = '" . escape_quote( $word ) . "';\n";
}
# set an element of the JavaScript 'suggs' array to a list of suggestions
function print_suggs_elem( $suggs, $index, $text_input_idx ) {
echo "suggs[$text_input_idx][$index] = [";
foreach( $suggs as $key=>$val ) {
if( $val ) {
echo "'" . escape_quote( $val ) . "'";
if ( $key+1 < count( $suggs )) {
echo ", ";
}
}
}
echo "];\n";
}
# escape single quote
function escape_quote( $str ) {
return preg_replace ( "/'/", "\\'", $str );
}
# handle a server-side error.
function error_handler( $err ) {
echo "error = '" . preg_replace( "/['\\\\]/", "\\\\$0", $err ) . "';\n";
}
## get the list of misspelled words. Put the results in the javascript words array
## for each misspelled word, get suggestions and put in the javascript suggs array
function print_checker_results() {
global $aspell_prog;
global $aspell_opts;
global $tempfiledir;
global $textinputs;
global $input_separator;
$aspell_err = "";
# create temp file
$tempfile = tempnam( $tempfiledir, 'aspell_data_' );
# open temp file, add the submitted text.
if( $fh = fopen( $tempfile, 'w' )) {
for( $i = 0; $i < count( $textinputs ); $i++ ) {
$text = urldecode( $textinputs[$i] );
// Strip all tags for the text. (by FredCK - #339 / #681)
$text = preg_replace( "/<[^>]+>/", " ", $text ) ;
$lines = explode( "\n", $text );
fwrite ( $fh, "%\n" ); # exit terse mode
fwrite ( $fh, "^$input_separator\n" );
fwrite ( $fh, "!\n" ); # enter terse mode
foreach( $lines as $key=>$value ) {
# use carat on each line to escape possible aspell commands
fwrite( $fh, "^$value\n" );
}
}
fclose( $fh );
# exec aspell command - redirect STDERR to STDOUT
$cmd = "$aspell_prog $aspell_opts < $tempfile 2>&1";
if( $aspellret = shell_exec( $cmd )) {
$linesout = explode( "\n", $aspellret );
$index = 0;
$text_input_index = -1;
# parse each line of aspell return
foreach( $linesout as $key=>$val ) {
$chardesc = substr( $val, 0, 1 );
# if '&', then not in dictionary but has suggestions
# if '#', then not in dictionary and no suggestions
# if '*', then it is a delimiter between text inputs
# if '@' then version info
if( $chardesc == '&' || $chardesc == '#' ) {
$line = explode( " ", $val, 5 );
print_words_elem( $line[1], $index, $text_input_index );
if( isset( $line[4] )) {
$suggs = explode( ", ", $line[4] );
} else {
$suggs = array();
}
print_suggs_elem( $suggs, $index, $text_input_index );
$index++;
} elseif( $chardesc == '*' ) {
$text_input_index++;
print_textindex_decl( $text_input_index );
$index = 0;
} elseif( $chardesc != '@' && $chardesc != "" ) {
# assume this is error output
$aspell_err .= $val;
}
}
if( $aspell_err ) {
$aspell_err = "Error executing `$cmd`\\n$aspell_err";
error_handler( $aspell_err );
}
} else {
error_handler( "System error: Aspell program execution failed (`$cmd`)" );
}
} else {
error_handler( "System error: Could not open file '$tempfile' for writing" );
}
# close temp file, delete file
unlink( $tempfile );
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="<?php echo $spellercss ?>" />
<script language="javascript" src="<?php echo $word_win_src ?>"></script>
<script language="javascript">
var suggs = new Array();
var words = new Array();
var textinputs = new Array();
var error;
<?php
print_textinputs_var();
print_checker_results();
?>
var wordWindowObj = new wordWindow();
wordWindowObj.originalSpellings = words;
wordWindowObj.suggestions = suggs;
wordWindowObj.textInputs = textinputs;
function init_spell() {
// check if any error occured during server-side processing
if( error ) {
alert( error );
} else {
// call the init_spell() function in the parent frameset
if (parent.frames.length) {
parent.init_spell( wordWindowObj );
} else {
alert('This page was loaded outside of a frameset. It might not display properly');
}
}
}
</script>
</head>
<!-- <body onLoad="init_spell();"> by FredCK -->
<body onLoad="init_spell();" bgcolor="#ffffff">
<script type="text/javascript">
wordWindowObj.writeBody();
</script>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
360Eshop电子商务网站建站系统 (1139个子文件)
360eshopdata.asa 1.65MB
config.ascx 5KB
360eshopdate_book.asp 268KB
cart_shop.asp 68KB
shop.asp 60KB
easp.asp 55KB
easp.asp 55KB
pays.asp 44KB
Admin_Article.asp 30KB
editproduct.asp 27KB
addproduct.asp 26KB
pay.asp 22KB
admin.asp 20KB
viewdingdan.asp 19KB
SmallCategoryManage.asp 19KB
viewdingdan_FHY.asp 18KB
webconfig.asp 18KB
anclass.asp 18KB
dingdan.asp 18KB
List_new.asp 18KB
List.asp 18KB
JSONdiscode.asp 18KB
Class.asp 17KB
nclass.asp 17KB
pay.asp 17KB
Admin_ArticleTemplateManage.asp 17KB
md5.asp 16KB
Admin_User.asp 16KB
editdingdan.asp 16KB
BigCategoryManage.asp 16KB
editdingdan2.asp 16KB
saveaddproduct.asp 16KB
editdingdan_fhy2.asp 15KB
editdingdan_fhy.asp 15KB
freeaspupload.asp 15KB
freeaspupload.asp 15KB
creat_WholeSite.asp 14KB
manageproduct.asp 14KB
Admin_BulletinManage.asp 14KB
index.asp 14KB
Research.asp 13KB
function.asp 13KB
Admin_First.asp 13KB
listuser.asp 13KB
md5.asp 12KB
Admin_Category.asp 12KB
guanggao.asp 12KB
pinpai.asp 12KB
head.asp 11KB
new.asp 11KB
nclass.asp 11KB
Alipay_md5.asp 11KB
pay_md5.asp 11KB
Admin_WebContent.asp 10KB
me_shouhuo.asp 10KB
Quoted_Price.asp 10KB
class_upload.asp 10KB
inc_md5.asp 9KB
checkuserlogin.asp 9KB
managepinglun.asp 9KB
anclass.asp 9KB
Admin_ArticleCodeBuild.asp 9KB
Getpwds.asp 9KB
io.asp 9KB
Regsave.asp 9KB
xclass.asp 9KB
search.asp 9KB
gouwu.asp 9KB
manageuser.asp 8KB
inc_common.asp 8KB
index.asp 8KB
tjbb2_fhy.asp 8KB
tjbb2.asp 8KB
webtop.asp 8KB
Admin_Config.asp 8KB
Admin_Notice.asp 8KB
me.asp 7KB
jiage.asp 7KB
listpl.asp 7KB
ubb.asp 7KB
help_index.asp 7KB
qq.asp 7KB
me_dangan.asp 7KB
Code.asp 7KB
tjbb.asp 7KB
pingpaimanage.asp 7KB
tjbb_fhy.asp 7KB
ziduanmanage.asp 7KB
sysset.asp 6KB
rss_class.asp 6KB
config.asp 6KB
class_html.asp 6KB
yck.asp 6KB
yck2.asp 6KB
Reg.asp 6KB
commands.asp 6KB
fckeditor.asp 6KB
Notice.asp 6KB
bankset.asp 5KB
reply.asp 5KB
共 1139 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
ZZXXLL1234
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- HM2305B-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 基于52单片机、ADC0832、LCD1602、两个74HC393和一个74HC08的频率测量计 不能用,请私我
- HM2302-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- python实战项目-学生成绩管理系统(基础版)
- 微信小程序源码 实现查公交 滴滴公交 app 源码下载
- HM2302E-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 基于C#图片相似度比较,感知哈希算法
- VR开发的概要介绍与分析
- 自动驾驶定位系列教程七:点云畸变补偿.pdf
- HM2302D-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功