KindEditor是一套开源的HTML可视化编辑器,主要用于让用户在网站上获得所见即所得编辑效果,兼容IE、Firefox、Chrome、 Safari、Opera等主流浏览器。KindEditor使用javaScript编写,可以无缝的于Java、.NET、PHP、asp等程序接 合。 KindEditor非常适合在CMS、商城、论坛、博客、Wiki、电子邮件等互联网应用上使用,2006年7月首次发布2.0以 来,KindEditor依靠出色的用户体验和领先的技术不断扩大编辑器市场占有率,目前在国内已经成为最受欢迎的编辑器之一。
听说是国产的支持一下,还挺好用的就是。
1 <html> 2 <head> 3 <meta charset="utf-8" /> 4 <title>Use KindEditor For PHP</title> 5 <link rel="stylesheet" href="../themes/default/default.CSS" /> 6 <link rel="stylesheet" href="../plugins/code/PRettify.css" /> 7 <script charset="utf-8" src="../kindeditor-min.js"></script> 8 <script charset="utf-8" src="../lang/zh_CN.js"></script> 9 <script charset="utf-8" src="../plugins/code/prettify.js"></script>10 <script>11 KindEditor.ready(function(K) {12 var editor1 = K.create('textarea[name="content1"]', {13 cssPath : '../plugins/code/prettify.css',14 uploadJson : '../php/upload_json.php',15 fileManagerJson : '../php/file_manager_json.php',16 allowFileManager : true,17 afterCreate : function() {18 var self = this;19 K.ctrl(document, 13, function() {20 self.sync();21 K('form[name=example]')[0].submit();22 });23 K.ctrl(self.edit.doc, 13, function() {24 self.sync();25 K('form[name=example]')[0].submit();26 });27 }28 });29 prettyPrint();30 });31 KindEditor.ready(function(K) {32 var editor = K.editor({33 allowFileManager : true34 });35 K('#image1').click(function() {36 editor.loadPlugin('image', function() {37 editor.plugin.imageDialog({38 imageUrl : K('#url1').val(),39 clickFn : function(url, title, width, height, border, align) {40 K('#url1').val(url);41 editor.hideDialog();42 }43 });44 });45 }); 46 });47 </script>48 </head>49 <body> 50 <form name="example" method="post" action="savegoods.php">51 <p>标题:<input type="text" name="title" id="title" value="title" /></p>52 <p>类别: <select name="kinds"><option value="xian" selected>鲜奶 <option value="suan">酸奶 </select></p>53 <p>封面图片:<input type="text" name="url1" id="url1" value="" /> <input type="button" id="image1" value="选择图片" />(网络图片 + 本地上传)</p>54 <p>封面描述:<input type="text" name="description" id="description" value="description" /></p>55 <p>内容:</p>56 <textarea name="content1" style="width:700px;height:200px;visibility:hidden;">s</textarea> 57 <br />58 <input type="submit" name="button" value="提交内容" /> (提交快捷键: Ctrl + Enter)59 </form>60 </body>61 </html>Use KindEditor For PHP
1 <?php 2 header("Content-type: text/html; charset=utf-8"); 3 $htmlData = ''; 4 if (!empty($_POST['content1'])) { 5 if (get_magic_quotes_gpc()) { 6 $htmlData = stripslashes($_POST['content1']); 7 } else { 8 $htmlData = $_POST['content1']; 9 } 10 if(!empty($_POST['url1']))11 echo "My_URL:".$_POST['url1']."</br>";12 if(!empty($_POST['kinds']))13 echo "My_Value:".$_POST['kinds']."</br>";14 echo "My_Content:".$htmlData; 15 }16 ?>savegoods.php
另外收得一个加解密类
1 <?php 2 function keyED($txt,$encrypt_key) 3 { 4 $encrypt_key = md5($encrypt_key); 5 $ctr=0; 6 $tmp = ""; 7 for ($i=0;$i<strlen($txt);$i++) 8 { 9 if ($ctr==strlen($encrypt_key)) $ctr=0;10 $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);11 $ctr++;12 }13 return $tmp;14 }15 16 //加密码函数17 function encrypt($txt,$key)18 {19 //srand((double)microtime()*1000000);20 $encrypt_key = md5(rand(0,320000000));21 $ctr=0;22 $tmp = "";23 for ($i=0;$i<strlen($txt);$i++)24 {25 if ($ctr==strlen($encrypt_key)) $ctr=0;26 $tmp.= substr($encrypt_key,$ctr,1) .27 (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));28 $ctr++;29 }30 return keyED($tmp,$key);31 }32 33 //解密函数34 function decrypt($txt,$key)35 {36 $txt = keyED($txt,$key);37 $tmp = "";38 for ($i=0;$i<strlen($txt);$i++)39 {40 $md5 = substr($txt,$i,1);41 $i++;42 $tmp.= (substr($txt,$i,1) ^ $md5);43 }44 return $tmp;45 }46 $string = "123456";47 //$string = "各位这是我做的加密码文件哦.";48 49 // 开始加密 encrypt $string, and store it in $enc_text50 $enc_text = encrypt($string,$key);51 52 // 开始解密 decrypt the encrypted text $enc_text, and store it in $dec_text53 $dec_text = decrypt($enc_text,$key);54 print "原始字符串 : $string <Br>\n";55 print "加密后字串 : $enc_text <Br>\n";56 print "解密后字串 : $dec_text <Br>\n";57 ?>ED code
savegoods.php显示~
KindEditor 下载地址:http://kindeditor.net/index.php