新浪编辑器的调用

 更新时间:2016年11月25日 16:05  点击:1810

require_once('cls.small_editor.php');
$obj = new SmallEditor();
$obj -> setEditor($e_form_name,$e_form_value,$width,$height);

<?php
        /*===========================================================
        = 版权协议:
        =        GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
        =------------------------------------------------------------
        = 文件名称:cls.small_editor.php
        = 摘    要:轻量级HTML编辑器 for PHP5
        = 版    本:1.0
        =------------------------------------------------------------
        = Script Written By phpwms项目组
        = 最后更新:xinge
        = 最后日期:2008-07-24
        ============================================================*/
        
        !defined('IN_SYS') and die('Hacking attempt');

        class SmallEditor {
               
                public $editor_dir = 'editor/SMALLeditor/';
               
                public function  __construct() {
                        global $root_dir;
                        $this -> editor_dir = $root_dir.$this -> editor_dir;
                        ob_start(array($this,'callBack'));
                }

                // 初始化
                private function editorInit() {
                        $str  = '<link rel="stylesheet" type="text/css" href="'.$this -> editor_dir.'comm.css" />'."\n";
                        $str .= '<script type="text/javascript" language="JavaScript" src="'.$this -> editor_dir.'all.js"></script>'."\n";
                        $str .= '<script type="text/javascript" language="JavaScript" src="'.$this -> editor_dir.'editor.js"></script>'."\n";
                        $str .= '<script type="text/javascript" language="JavaScript" src="'.$this -> editor_dir.'editor_toolbar.js"></script>'."\n";
                        return $str;
                }

                // 回调替换
                public function callBack($buffer) {
                        return (str_replace(array('</HEAD>','</Head>','</head>'),$this -> editorInit().'</HEAD>', $buffer));
                }

                public function setEditor($e_form_name = 'my_text_area',$e_form_value = '',$e_toolbar = 'AdminMode',$height='',$width = '100%') {
                        !$height and $height = 230;
                        !strstr($height,'%') and $height = $height.'px';
                        !strstr($width,'%')  and $width  = $width.'px';
                        return <<<EOF
                <textarea id="{$e_form_name}" name="{$e_form_name}" style="display:none;">{$e_form_value}</textarea>
                <script language="javascript">
                        gContentId = "{$e_form_name}";
                        OutputEditorLoading();
                </script>
                <iframe id="HtmlEditor" class="editor_frame" frameborder="0" marginheight="0" marginwidth="0" style="width:{$width};height:{$height};overflow:visible;" hideFocus></iframe>
EOF;
                }
        }
?>新浪编辑器的调用

php file_get_contents读取远程文件并输出,这样做的好得就是不会在flash播放代码中显示对方网站的文件地址,下面是我自己用的一个.是读取方视频文件用的.

<?php
require_once("s/s.php");
 $a_id =get_value('id','');
 if(is_numeric($a_id) ){
                                            
   $result =mysql_query("Select * from s where id='$a_id'") or die(mysql_error());
   
   if( mysql_num_rows($result) ){
   
     $rs  =mysql_fetch_array( $result );     
     
     $swfpath=$rs[5];
     
   }
 }
 
 function Get_swf($url){
    
  $data = file_get_contents($url);
  
  header("content-type: application/x-shockwave-flash");
  
  echo $data;

 }
?>
本站原创:  www.111cn.net   转载请注明来处.

 +----------------------------------------------------------
         * @param mixed $where 数据
         * @param string $tables  数据表名
         * @param string $fields  字段名
         * @param string $order  排序
         * @param string $limit
         * @param string $group
         * @param string $having
         * @param boolean $cache 是否缓存
         * @param boolean $lazy 是否惰性加载
         * @param boolean $lock 是否加锁
         +----------------------------------------------------------
         * @return ArrayObject
         +----------------------------------------------------------
         * @throws ThinkExecption
         +----------------------------------------------------------
         */
        public function find($where,$tables,$fields='*',$order=null,$limit=null,$group=null,$having=null,$join=null,$cache=false,$lazy=false,$lock=false)
        {
                if(in_array($this->getDbType(),array('MSSQL','IBASE'),true) ) {
                        $this->queryStr = 'SELECT '.$this->parseLimit($limit)
                        .$this->parseFields($fields)
                        .' FROM '.$tables
                        .$this->parseJoin($join)
                        .$this->parseWhere($where)
                        .$this->parseGroup($group)
                        .$this->parseHaving($having)
                        .$this->parseOrder($order);
                }else{
                        $this->queryStr = 'SELECT '.$this->parseFields($fields)
                        .' FROM '.$tables
                        .$this->parseJoin($join)
                        .$this->parseWhere($where)
                        .$this->parseGroup($group)
                        .$this->parseHaving($having)
                        .$this->parseOrder($order);
                        if("ORACLE" == $this->getDbType())
                                if($limit[0] <= 0){
                                        if($limit[1] > 0)
                                                $this->queryStr = "SELECT * FROM (".$this->queryStr.") WHERE ROWNUM <= ".$limit[1];
                                }else{
                                        $whereClause = "";
                                        if($limit[1] > 0)
                                                $whereClause = " WHERE ROWNUM <= ".($limit[0] + $limit[1]);

                                        $this->queryStr = "SELECT * FROM ( SELECT ROW_.*, ROWNUM ROWNUM_ FROM ("
                                                                          .$this->queryStr.") ROW_"
                                                                          .$whereClause
                                                                          .") WHERE ROWNUM_ > "
                                                          .$limit[0];
                                }
                        else
                                $this->queryStr .= $this->parseLimit($limit);
                }
                return $this->query('',$cache,$lazy,$lock);
        }

jquery与 ajax 简单例子

基于JQuery框架的AJAX
PS:本人这篇始发于PHPCHINA,发现被很多人转了,但却未注明出处,想了一下,还是自己转到这里来。
前几天发了个贴,分享了prototype框架关于AJAX方面的学习过程。然后有人说jquery框架更方便。

正好项目中准备使用thickbox,于是干脆抛弃prototype.js,看起jquery.js了。JQuery确实不错,体积比Prototype小了许多,而且使用起来更方便更灵活。有人说Prototype像JAVA,正统;而JQuery像Ruby,灵活,更趋于OOP。

小试了下AJAX,感觉比prototype简洁多了,在JQuery中,AJAX有三种实现方式:$.ajax(),$.post,$.get()。

XHTML(主要):
代码: 复制内容到剪贴板
<div id="result" style="backgroundrange;border:1px solid red;width:300px;height:400px;"></div>

<form id="formtest" action="" method="post">

<p><span>输入姓名:</span><input type="text" name="username" id="input1" /></p>

<p><span>输入年龄:</span><input type="text" name="age" id="input2" /></p>

<p><span>输入性别:</span><input type="text" name="sex" id="input3" /></p>

<p><span>输入工作:</span><input type="text" name="job" id="input4" /></p>

</form>

<button id="send_ajax">提交</button>

<button id="test_post">OST提交</button>

<button id="test_get">GET提交</button>
JS:
1、引入jquery框架:
代码: 复制内容到剪贴板
<script  type="text/javascript" src="../js/jquery.js"></script>
2、构建AJAX,JQUERY的好处是不需要在XHTML中使用JS代码来触发事件了,可以直接封装在JS文件中:
代码: 复制内容到剪贴板
<script type="text/javascript">

//$.ajax()方式

$(document).ready(function (){

   $('#send_ajax').click(function (){ //直接把onclick事件写在了JS中,而不需要混在XHTML中了

          var params=$('input').serialize(); //序列化表单的值,与prototype中的form.serialize()相同

         $.ajax({

               url :'ajax_test.php',  //后台处理程序

               type:'post',    //数据发送方式

             dataType:'json',  //接受数据格式

               data:params,  //要传递的数据

               success:update_page  //回传函数(这里是函数名)

               });

        });

});

function update_page (json) { //回传函数实体,参数为XMLhttpRequest.responseText

       var str="姓名:"+json.username+"";

       str+="年龄:"+json.age+"";

       str+="性别:"+json.sex+"";

       str+="工作:"+json.job;

       $("#result").html(str);

}

//$.post()方式:

$(function (){//$(document).ready(function (){ 的简写

      $('#test_post').click(function (){

                $.post('ajax_test.php',

               {username('#input1').val(),age('#input2').val(),sex('#input3').val(),job('#input4').val()},

                function (data){ //回传函数

                var myjson='';

               eval('myjson='+data+';');

               $('#result').html("姓名:"+myjson.username+"

工作:"+myjson['job']);

               });

       });

});

$.get()方式:

$(function (){

         $('#test_get').click(function (){

                     $.get('ajax_test.php',

                     {username("#input1").val(),age("#input2").val(),sex("#input3").val(),job("#input4").val()},

                     function  (data) {

                           var myjson='';

                           eval("myjson="+data+";");

                           $("#result").html(myjson.job);

                      });

           });

});

</script>
PHP代码:
代码: 复制内容到剪贴板
<?php

$arr=$_POST; //若以$.get()方式发送数据,则要改成$_GET.或者干脆_REQUEST

$myjson=json_encode($arr);

echo $myjson;

?>


<?php session_start(); ?>
<?php
{
$authcode = new AuthCode();
if ($authcode->GetUriFileName() == "authcode.php")
{
  $authcode->OutputImg();
}
}
function ChkAuthcode($Authcode)
{
if ($_SESSION['AuthCode'] == $Authcode)
{
  $rtn = true;
}
else
{
  $rtn = false;
}
$_SESSION['AuthCode'] = rand(0, 999999);
return $rtn;
}
class AuthCode
{
/* Public Variables */
/* Private Variables */
var $image;
#
var $sBgcolor;
var $nWidth;
var $nHeight;
var $nLen;
var $bNoise;
var $nNoise;
var $bBorder;
var $aFontlist;
/* Constractor */
function AuthCode()
{
  $this->sBgcolor = "#FFCC00";
  $this->nWidth = 70;
  $this->nHeight = 25;
  $this->nLeftMargin = 5;
  $this->nRightMargin = 5;
  $this->nTopMargin = 3;
  $this->nBottomMargin = 2;
  $this->nLen = 4;
  $this->bNoise = true;
  $this->nNoisePoint = 50;
  $this->nNoiseLine = 5;
  $this->bBorder = true;
 
  $this->aFontlist[0] = "./fonts/arial.ttf";
  $this->aFontlist[1] = "./fonts/comic.ttf";
  $this->aFontlist[2] = "./fonts/raavi.ttf";
  $this->aFontlist[3] = "./fonts/verdanai.ttf";
  $this->aFontlist[4] = "./fonts/tahoma.ttf";
  $this->aFontlist[5] = "./fonts/shruti.ttf";
  $this->aFontlist[6] = "./fonts/BKANT.TTF";
  $this->aFontlist[7] = "./fonts/comicbd.ttf";
  $this->aFontlist[8] = "./fonts/courbi.ttf";
  $this->aFontlist[9] = "./fonts/times.ttf";
}

function OutputImg()
{
  $this->image = "";
  $this->image = imagecreate($this->nWidth, $this->nHeight);
  $back = $this->getcolor($this->sBgcolor);
  imagefilledrectangle($this->image, 0, 0, $this->nWidth, $this->nHeight, $back);
  $size = ($this->nWidth - $this->nLeftMargin - $this->nRightMargin)/$this->nLen;
  if($size>($this->nHeight - $this->nTopMargin - $this->nBottomMargin))
   $size=$this->nHeight - $this->nTopMargin - $this->nBottomMargin;
 
  $left = ($this->nWidth-$this->nLen*($size+$size/10))/2 + $this->nLeftMargin;
  $code = "";
  for ($i=0; $i<$this->nLen; $i++)
  {
   $randtext = rand(0, 9);
   $code .= $randtext;
   $textColor = imagecolorallocate($this->image, rand(0, 100), rand(0, 100), rand(0, 100));
   $font = $this->aFontlist[rand(0,9)];//rand(1,4).".ttf";
   $randsize = rand($size-$size/10, $size+$size/10);
   $location = $left+($i*$size+$size/10);
   imagettftext($this->image, $randsize, rand(-18,18), $location, rand($size, $size+$size/5) + $this->nTopMargin, $textColor, $font, $randtext);
  }
  if($this->bNoise == true) $this->setnoise();
  $_SESSION['AuthCode'] = $code;
  $bordercolor = $this->getcolor("      ");
  if($border==true) imagerectangle($this->image, 0, 0, $this->nWidth-1, $this->nHeight-1, $bordercolor);
  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // date in the past
  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
  header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
  header("Cache-Control: post-check=0, pre-check=0", false);
  header("Cache-Control: private");
  header("Pragma: no-cache"); // HTTP/1.0
  header("Content-type: image/png");
  imagepng($this->image);
  imagedestroy($this->image);
 
  return $sAuthcode;
}
function ChkAuthcode($Authcode)
{
  if ($this->GetAuthcode() == $Authcode)
  {
   $rtn = true;
  }
  else
  {
   $rtn = false;
  }
  $_SESSION['AuthCode'] = rand(0, 999999);
  return $rtn;
}
function GetAuthcode()
{
  $x_AuthCode = $_SESSION['AuthCode'];
  $_SESSION['AuthCode'] = rand(0, 999999);
  return $x_AuthCode;
}
 
/* Private Functions */
function GetUriFileName()
{
  return substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], '/') + 1 , strlen($_SERVER['SCRIPT_NAME']) - strrpos($_SERVER['SCRIPT_NAME'], '/'));
}
function setnoise()
{
  for ($i=0; $i<$this->nNoiseLine; $i++){
   $randColor = imagecolorallocate($this->image, rand(0, 255), rand(0, 255), rand(0, 255));
   imageline($this->image, rand(0, $this->nWidth), rand(0, $this->nHeight), rand(0, $this->nWidth), rand(0, $this->nHeight), $randColor);
  }
 
  for ($i=0; $i<$this->nNoisePoint; $i++){
   $randColor = imagecolorallocate($this->image, rand(0, 255), rand(0, 255), rand(0, 255)); 
   imagesetpixel($this->image, rand(0, $this->nWidth), rand(0, $this->nHeight), $randColor);
  }
}
function getcolor($color)
{
   $color = eregi_replace ("^#","",$color);
   $r = $color[0].$color[1];
   $r = hexdec ($r);
   $b = $color[2].$color[3];
   $b = hexdec ($b);
   $g = $color[4].$color[5];
   $g = hexdec ($g);
   $color = imagecolorallocate ($this->image, $r, $b, $g);
   return $color;
}
}
?>
[!--infotagslink--]

相关文章

  • Spring AOP 对象内部方法间的嵌套调用方式

    这篇文章主要介绍了Spring AOP 对象内部方法间的嵌套调用方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-08-29
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • c# 三种方法调用WebService接口

    这篇文章主要介绍了c# 三种方法调用WebService接口的相关资料,文中示例代码非常详细,帮助大家更好的理解和学习,感兴趣的朋友可以了解下...2020-07-07
  • c# WPF中通过双击编辑DataGrid中Cell的示例(附源码)

    这篇文章主要介绍了c# WPF中通过双击编辑DataGrid中Cell的示例(附源码),帮助大家更好的理解和学习使用c#,感兴趣的朋友可以了解下...2021-03-03
  • js实现调用网络摄像头及常见错误处理

    这篇文章主要介绍了js实现调用网络摄像头及常见错误处理,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-07
  • c#动态调用Webservice的两种方法实例

    这篇文章介绍了c#动态调用Webservice的两种方法实例,有需要的朋友可以参考一下...2020-06-25
  • c#中WebService的介绍及调用方式小结

    这篇文章主要给大家介绍了关于c#中的WebService及其调用方式的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
  • 解决Vue watch里调用方法的坑

    这篇文章主要介绍了解决Vue watch里调用方法的坑,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-07
  • 解决vue watch数据的方法被调用了两次的问题

    这篇文章主要介绍了解决vue watch数据的方法被调用了两次的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-07
  • C#中加载dll并调用其函数的实现方法

    下面小编就为大家带来一篇C#中加载dll并调用其函数的实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • PHP调用MySQL存储过程并返回值实现程序

    本文章来给大家详细介绍在php中如何来调用执行mysql存储过程然后返回由存储过程返回的值了,有需要了解的同学可进入参考。 。调用存储过程的方法。 a。如果存储过...2016-11-25
  • C#异步调用的好处和方法分享

    我们要明确,为什么要进行异步回调?众所周知,普通方法运行,是单线程的,如果中途有大型操作(如:读取大文件,大批量操作数据库,网络传输等),都会导致方法阻塞,表现在界面上就是,程序卡或者死掉,界面元素不动了,不响应了...2020-06-25
  • C#调用python脚本的方法步骤(2种)

    这篇文章主要介绍了C#调用python脚本的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
  • javascript实现方法调用与方法触发小结

    这篇文章主要介绍了javascript实现方法调用与方法触发小结的相关资料,需要的朋友可以参考下...2016-03-30
  • BootStrap和jQuery相结合实现可编辑表格

    这篇文章主要介绍了BootStrap和jQuery相结合实现可编辑表格的相关资料,需要的朋友可以参考下...2016-04-23
  • 浅谈PHP调用Webservice思路及源码分享

    方法一:直接调用复制代码 代码如下:<? /******************************************************************************/ /* 文件名 : soapclient.php /* 说 明 : WebService接口客户端例程 /****************...2014-06-07
  • 基于C#调用c++Dll结构体数组指针的问题详解

    下面小编就为大家分享一篇基于C#调用c++Dll结构体数组指针的问题详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-06-25
  • C# Soap调用WebService的实例

    下面小编就为大家带来一篇C# Soap调WebService的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-06-25
  • Python调用.NET库的方法步骤

    这篇文章主要介绍了Python调用.NET库的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-05-09
  • 基于C#调用OCX控件的常用方法(推荐)

    下面小编就为大家分享一篇基于C#调用OCX控件的常用方法推荐,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-06-25