Example #1
0
 /**
  * iframe嵌套指定url
  * 运行后直接退出此次请求
  * @param string $url 客户端跳转的URL
  */
 public static function iframe($url, $title = '', $description = '', $keywords = '')
 {
     $url = yyuc::url($url);
     $jquery = trim(Conf::$jquery_path) == '' ? Page::asset('@system/js/') . 'jquery.js' : Conf::$jquery_path;
     $appdenstr = '<script type="text/javascript" src="' . $jquery . '"></script><script type="text/javascript">function fitif(){jQuery("#mainoem").width(jQuery(window).width());jQuery("#mainoem").height(jQuery(window).height());jQuery("#mainoem").attr("src","' . $url . '");}jQuery(fitif);jQuery(window).resize(fitif);</script>';
     echo '<html><head><title>' . htmlentities($title) . '</title>' . $appdenstr . '<meta name="keywords" content="' . htmlentities($keywords) . '"/><meta name="description" content="' . htmlentities($description) . '"/></head><body style="margin: 0;padding: 0;overflow: hidden;"><iframe style="border: none;width: 100%;height: 100%;" src="about:blank"  frameborder="no" border="0"  id="mainoem"></iframe></body></html>';
     die;
 }
Example #2
0
/**
 * 验证码标签
 * @param string $text 要输入验证码的文本框ID 一定要在Form内部
 * @param string $local 要展现的验证码位置元素的ID 一定要在Form内部
 * @param boolean $sound 验证码是否开启声音提示功能
 * @param integer $width 宽度默认115
 * @param integer $height 高度默认30
 * @param integer $codenum 验证码字符个数默认4
 */
function YYUC_tag_vercode($text, $local, $sound = false, $width = 115, $height = 30, $codenum = 4)
{
    $YYSYS = Page::asset('@system/');
    $html = '<script>';
    $html .= '$(function(){$("#' . $text . '").data("mbl",1);$("#' . $text . '").blur();$("#' . $text . '").data("mbl",0);$("#' . $local . '").append(\'<input type="hidden" id="yyuc_verimg_tag"/>\');$("#' . $text . '").focus(function(){ if(!$("#yyuc_verimg").is("img")){';
    $html .= 'var verimg = $(\'<img id="yyuc_verimg" title="双击切换" />\');';
    $html .= 'verimg.attr("src","/@system/securimage/loadver-' . $width . '-' . $height . '-' . $codenum . Conf::$suffix . '?r="+Math.random());';
    $html .= '$("#' . $local . '").append(verimg);';
    if ($sound) {
        $soundurl = $YYSYS . 'securimage/securimage_play.swf?audio_file=/@system/securimage/loadsound' . Conf::$suffix . '&amp;bgColor1=#fff&amp;bgColor2=#fff&amp;iconColor=#777&amp;borderWidth=1&amp;borderColor=#000';
        $swfhtm = '<object type="application/x-shockwave-flash" data="' . $soundurl . '" height="32" width="32"><param name="movie" value="' . $soundurl . '"></object>';
        $html .= '$("#' . $local . '").append(\'' . $swfhtm . '\');';
    }
    $html .= 'verimg.dblclick(function(){ verimg.attr("src","/@system/securimage/loadver-' . $width . '-' . $height . '-' . $codenum . Conf::$suffix . '?r="+Math.random());})';
    $html .= '}});';
    $html .= 'var toyz = function(){if($.trim($("#' . $text . '").val())==""){return;}if($.trim($("#' . $text . '").val()).length!=' . $codenum . '){$("#' . $text . '").val("");return;};$("#' . $text . '").data("mbl",1);$("#' . $text . '").blur();$("#' . $text . '").data("mbl",0);$("#' . $text . '").attr("disabled",true);ajax("/@system/securimage/checkver' . Conf::$suffix . '",{"code":$.trim($("#' . $text . '").val())},function(m){if(m=="ok"){$("#' . $local . '").html("");}else{$("#' . $text . '").val("");$("#' . $text . '").attr("disabled",false);}});};';
    $html .= '$("#' . $text . '").keyup(function(){$(this).val($.trim($(this).val()));if($(this).val().length==' . $codenum . '){toyz();}});$("#' . $text . '").blur(function(){if($("#' . $text . '").data("mbl")==1){return;};toyz();});';
    $html .= '});</script>';
    return $html;
}
Example #3
0
 /**
  * 编译模板
  */
 public function _trans()
 {
     if (!@file_exists($this->com_path) || filemtime($this->com_path) < filemtime($this->view_path) || Conf::$is_developing) {
         //取得有效标示
         $this->ltg = '(?<!!)' . $this->_conver_tag(Conf::$left_tag);
         $this->rtg = '((?<![!]))' . $this->_conver_tag(Conf::$right_tag);
         //取得包裹路径
         $this->_view_wrap_path = dirname(YYUC_FRAME_PATH . 'view/' . Conf::$view_folder . '/@wrap/' . Page::$my_view);
         $comRes = $this->_complie_string($this->_getViewHtml($this->_view_wrap_path));
         //进行js引入替换
         $jquery = trim(Conf::$jquery_path) == '' ? Page::asset('@system/js/') . 'jquery.js' : Conf::$jquery_path;
         $jyyuc = Page::asset('@system/js/') . 'yyuc.js';
         $appdenstr = '</title><script type="text/javascript" src="' . $jquery . '"></script><script type="text/javascript">window.yyuc_jspath = "' . Page::asset('@system/') . '";</script></script><script type="text/javascript" src="' . $jyyuc . '"></script>';
         $comRes = str_replace('</title>', $appdenstr, $comRes);
         $appdenstr = '</TITLE><script type="text/javascript" src="' . $jquery . '"></script><script type="text/javascript">window._$=jQuery.noConflict();window.yyuc_jspath = "' . Page::asset('@system/') . '";</script><script type="text/javascript" src="' . $jyyuc . '"></script>';
         $comRes = str_replace('</TITLE>', $appdenstr, $comRes);
         if (!Conf::$is_developing) {
             //执行JS压缩加密
             $j_cs = explode('//@jsbegin', $comRes);
             $j_csn = count($j_cs);
             if ($j_csn > 1) {
                 $newcomRes = '';
                 for ($i = 0; $i < $j_csn; $i++) {
                     if ($i > 0) {
                         $js_cs = explode('//@jsend', $j_cs[$i]);
                         $packer = new JavaScriptPacker($js_cs[0], 62, false, true);
                         $newcomRes .= $packer->pack();
                         $newcomRes .= $js_cs[1];
                     } else {
                         $newcomRes .= $j_cs[$i];
                     }
                 }
                 $comRes = $newcomRes;
             }
         }
         File::creat_dir_with_filepath($this->com_path);
         file_put_contents($this->com_path, $comRes);
     } else {
         return;
     }
 }
Example #4
0
    /**
     * 文件上传插件<br/>
     * $config的配置说明:<br/>
     * width:上传按钮的宽度(integer)<br/>
     * height:上传按钮的高度(integer)<br/>
     * fontSize:上传按钮的文本大小(integer :15)(单位:px)<br/>
     * text:上传按钮的文本内容(string)<br/>
     * fontColor:上传按钮的文本颜色(string :#000000)<br/>
     * backgroundImg:上传按钮的背景图片(string :/media/images/bg.jpg)<br/>
     * filenameSize:文件名称的文本大小(integer :15)(单位:px)<br/>
     * filenameColor:文件名称的文本颜色(string :#000000)<br/>
     * style:上传控件的一些必要的样式补充,不会覆盖原有样式定义(string :margin-top:10px;)<br/>
     * size:上传文件的大小限制(integer :150)(单位:KB)<br/>
     * type:上传文件的类型限制(string :jpg,gif,png)<br/>
     * onfailure:上传失败后回调的JS函数名称(string :alert)<br/>
     * onsuccess:上传成功后回调的JS函数名称,不设置则不调用,回传参数为上传文件的访问URL(string :alert)<br/>
     * showdel:是否显示删除上传文件的按钮,默认为:false,自定义URL的情况下该参数无效,请自行添加删除方法(string :false)<br/>
     * ondel:删除按钮点击后的JS函数名称,不设置则不调用,回传参数为上传文件的访问URL(string :alert)<br/>
     * $data为 文件上传中的附带的提交信息默认为空数组(string : array('name'=>'xiaoming','age'=>'18')   )<br/>
     * $url 为用户处理上传的请求URL地址,一般编辑页面使用。连同Form提交的新增页面一般用 tosave_upload_file($name,$path)<br/>
     * $picareaid 为图片文件上传后要显示的位置 不设置则不显示<br/>
     * $cutpic 是图片剪切的相关配置,不设置则不会进行剪切处理:<br/>
     * buttonStyle:剪切确认提交的按钮样式(string :margin-top:10px;)<br/>
     * buttonClass:css样式
     * buttonText:剪切确认提交的按钮文本(string :确定剪裁;)<br/>
     * width:剪切图片的目标宽度,不设置则不限定(integer :15)(单位:px)<br/>
     * height:剪切图片的目标高度,不设置则不限定(integer :15)(单位:px)<br/>
     * onsuccess:剪切成功后回调的JS函数名称,不设置则不调用,回传参数为文件的访问URLURL(string :alert)<br/>
     * @param string $name 标签name要求唯一
     * @param array $config 上传文件的配置信息
     * @param array $data 文件上传中的附带提交信息
     * @param string $url 文件上传提交的URL
     * @param string $picareaid 图片文件上传后要显示的位置ID
     * @param array $cutpic 图片上传后需要剪裁的相关配置
     */
    public static function init($name, $config = null, $data = null, $url = null, $picareaid = null, $cutpic = null)
    {
        $YYSYS = Page::asset('@system/');
        $STA = Conf::$remote_path == '' ? '/' : Conf::$remote_path;
        if ($url == null) {
            $url = '/@system/upload.html';
        }
        $picareaid = trim($picareaid);
        $value = '';
        if (is_null(self::$_model)) {
            $value = YYUC_getNameValue($name);
        } else {
            $value = trim(self::$_model->{$name});
            $name = self::$_model->field_form_name($name);
        }
        if (!isset($config)) {
            $config = array();
        }
        if (!isset($data)) {
            $data = array();
        }
        if (!is_array($config)) {
            $picareaid = $config;
            $config = array();
        }
        $sysconfig = array('width' => 100, 'height' => 32, 'fontSize' => 15, 'filenameSize' => 13, 'text' => '上传文件', 'class' => '', 'filenameColor' => '#000000', 'fontColor' => '#000000', 'backgroundImg' => '', 'size' => 600, 'type' => 'jpg,gif,png,jpeg,bmp,xls,doc,xlsx,docx,rar,zip,ppt,pptx,txt', 'onfailure' => 'alert', 'onselect' => 'false', 'onsuccess' => 'false', 'ondel' => 'false', 'showdel' => false, 'showfilename' => false, 'showbfb' => false, 'style' => '', 'btnstyle' => '');
        $config = array_merge($sysconfig, $config);
        $ttid = 'YYUC_' . md5('YYUC_UPLOAD_' . $name . microtime());
        $surl = $url;
        $width = $config['width'];
        $class = $config['class'];
        $height = intval($config['height']);
        $lineheight = intval($height / 5 * 4);
        $fontSize = $config['fontSize'];
        $filenameSize = $config['filenameSize'];
        $text = $config['text'];
        $filenameColor = $config['filenameColor'];
        $fontColor = $config['fontColor'];
        $backgroundImg = trim($config['backgroundImg']);
        $btntype = "button";
        if ($backgroundImg != '') {
            $btntype = "image";
        }
        $size = $config['size'];
        $_SESSION['YYUC_last_upsizelimit'] = $size;
        $type = $config['type'];
        $onfailure = $config['onfailure'];
        $onselect = $config['onselect'];
        $onsuccess = $config['onsuccess'];
        $ondel = $config['ondel'];
        $showdel = $config['showdel'];
        $showfilename = $config['showfilename'];
        $showbfb = $config['showbfb'];
        $style = $config['style'];
        $btnstyle = $config['btnstyle'];
        $htm = '';
        if (is_array($cutpic)) {
            $htm = '<input type="hidden" relobj="yyuccutpic" rel="yyuc" />';
            $url = '/@system/upload.html';
            $cutwidth = isset($cutpic['width']) ? intval($cutpic['width']) : 0;
            $cutheight = isset($cutpic['height']) ? intval($cutpic['height']) : 0;
            $buttonStyle = isset($cutpic['buttonStyle']) ? $cutpic['buttonStyle'] : '';
            $buttonClass = isset($cutpic['buttonClass']) ? $cutpic['buttonClass'] : '';
            $buttonText = isset($cutpic['buttonText']) ? $cutpic['buttonText'] : '确定剪裁';
            if ($cutwidth == 0 || $cutheight == 0) {
                $aspectRatio = 'null';
            } else {
                $aspectRatio = $cutwidth / $cutheight;
            }
            $oncutsuccess = isset($cutpic['onsuccess']) ? $cutpic['onsuccess'] : 'false';
        } else {
            $url = $surl;
        }
        $htm .= <<<EOT
<iframe name="{$ttid}_if" style="position:absolute; left:-10000px;"></iframe>
<table  style="border:none;padding:0;margin:0;width:auto;display: inline-block;"><tr style="border:none;padding:0;margin:0;"><td style="border:none;padding:0;margin:0;width:auto;">
<div style="display:none" id="{$ttid}_div" action="{$url}" method="post" enctype="multipart/form-data" target="{$ttid}_if">
<span style="{$style}display:-moz-inline-box;display:inline-block;width:{$width}px;height:{$height}px;line-height: {$height}px;position: relative;">
<input name="YYUC_UPLOAD_file" style="position: absolute;height: 100%;width:{$width}px;right: 0;z-index:100000" type="file"/>
EOT;
        if ($btntype == 'button') {
            $htm .= <<<EOT
<button class="{$class}" style="{$btnstyle}display:block; position: absolute;height: 100%;z-index:99999;">{$text}</button>
EOT;
        } else {
            $htm .= <<<EOT
<input src="{$backgroundImg}" class="{$class}" type="{$btntype}" style="{$btnstyle}display:block; position: absolute;height: 100%;width:100%;z-index:1;line-height: {$lineheight}px;font-size:{$fontSize}px;color:{$fontColor};text-align: center;" value="{$text}"/>
EOT;
        }
        $htm .= <<<EOT
</span>
<input type="hidden" name="YYUC_UPLOAD_SIZE" value="{$size}"/>
<input type="hidden" name="YYUC_UPLOAD_ID" value="{$ttid}"/>
EOT;
        //隐参添加
        foreach ($data as $k => $v) {
            $htm .= '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars($v, ENT_QUOTES) . '"/>';
        }
        $htm .= <<<EOT
</div>
</td><td style="border:none;padding:0;margin:0;width:auto;">
<span id="{$ttid}_span" style="display:-moz-inline-box;display:inline-block;width:{$width}px;height:{$height}px;">
</span>
</td>
EOT;
        //删除按钮
        if ($showdel) {
            $htm .= '<td style="border:none;padding:0;margin:0;width:auto;"><span id="' . $ttid . '_del" style="display: none;height:' . $height . 'px;line-height: ' . $height . 'px;"><img src="' . $YYSYS . 'img/close.png" syle="cursor:pointer;" title="删除"/></span></td>';
        }
        $htm .= <<<EOT
<td style="border:none;padding:0;margin:0;width:auto;"><span id="{$ttid}_loadpic" style="display: none;"><img src="{$YYSYS}img/loading/18.gif"/></span></td>
EOT;
        if ($showbfb) {
            $htm .= <<<EOT
<td style="border:none;padding:0;margin:0;width:auto;"><span id="{$ttid}_bfb" style="line-height:{$height}px;color:{$filenameColor};font-size:{$filenameSize}px;"></span></td>
EOT;
        }
        if ($showfilename) {
            $htm .= <<<EOT
<td style="border:none;padding:0;margin:0;width:auto;"><span id="{$ttid}_name" style="line-height:{$height}px;color:{$filenameColor};font-size:{$filenameSize}px;"></span></td>
EOT;
        }
        $htm .= <<<EOT
</tr></table>
<input type="hidden" name="{$name}" id="{$ttid}_text" value="{$value}"/>
<script>
\$(function(){
EOT;
        //隐参添加
        if ($showdel && $value != '') {
            $htm .= '$("#' . $ttid . '_del").css("cursor","pointer").show();';
        }
        if ($picareaid != '' && $value != '') {
            $htm .= "\n\$('#{$picareaid}').html('<img src=\"{$value}?_='+(new Date()).getTime()+'\"/>');\n";
        }
        if ($showdel) {
            $htm .= <<<EOT
window.{$ttid}_clear = function(){
\t\$('#{$ttid}_bfb').html('');
\t\$('#{$ttid}_name').html('');
\tif('{$picareaid}'!=''){ \$('#{$picareaid}').html('');}
\t\$('#{$ttid}_del').hide();
\tvar oldkey = \$.trim(\$('#{$ttid}_text').val());
\tif(oldkey!=''&&oldkey.indexOf('/')==0){
\t\t\$('#{$ttid}_text').val('@-@'+oldkey);
\t}else if(oldkey.indexOf('@-@')!=-1){
\t\tvar oldkey2 = oldkey.split('@-@');
\t\t\$('#{$ttid}_text').val('@-@'+oldkey2[1]);
\t}else{
\t\t\$('#{$ttid}_text').val('');
\t}
}
\$('#{$ttid}_del').click(function(){
\tif(!confirm('确定要删除吗?')){return;}
\twindow.{$ttid}_clear();
\tif({$ondel}){
\t\t{$ondel}('oldkey','{$ttid}');
\t}
});
EOT;
        }
        $htm .= <<<EOT
\tvar {$ttid}_form = window.{$ttid}_form = \$('<form style="position: absolute;left:-10000px;" id="{$ttid}" action="{$url}" method="post" enctype="multipart/form-data" target="{$ttid}_if"></form>');
\t\$('body').append({$ttid}_form);
\t{$ttid}_form.html(\$('#{$ttid}_div').html());
\t\$('#{$ttid}_div').remove();
\twindow.{$ttid}_resize = function(){
\tif(\$('#{$ttid}_span').is(':hidden')){
\t\t{$ttid}_form.hide();
\t}else{
\t\t{$ttid}_form.show();
\t\tvar {$ttid}_offset = \$('#{$ttid}_span').offset();
\t\t{$ttid}_form.css('left',{$ttid}_offset.left).css('top',{$ttid}_offset.top);
\t}
  \t\t
\t};
\tsetInterval(window.{$ttid}_resize,55);
\tvar {$ttid}pic = \$('#{$ttid}').find('input[name="YYUC_UPLOAD_file"]');
\t{$ttid}pic.css('opacity',0);
\t{$ttid}pic.change(function(){
\t\tvar thefiles = \$(this).val().replaceAll('\\\\','/').split('/');
\t\tvar filename = thefiles[thefiles.length-1];
\t\tif(\$.trim(filename)==''){
\t\t\treturn;
\t\t}
\t\t//后缀校验
\t\tvar needsuffixs = ',{$type},'.toLowerCase();
\t\tvar suffixs = filename.split('.');
\t\tif(needsuffixs.indexOf((','+suffixs[suffixs.length-1]+',').toLowerCase())==-1){
\t\t\tif({$onfailure}){
\t\t\t\t{$onfailure}('文件格式不被允许',\$('#{$ttid}'),1,'{$ttid}');
\t\t\t}
\t\t}else{
EOT;
        //选中事件
        if ($onselect != 'false') {
            $htm .= <<<EOT
\t\t\tif({$onselect}){
\t\t\t\tif(!{$onselect}(filename,\$('#{$ttid}'),'{$ttid}')){
\t\t\t\t\treturn;
\t\t\t\t}
\t\t\t}
EOT;
        }
        $htm .= <<<EOT
\t\t\t\$('#{$ttid}_name').html(filename);
\t\t\twindow.{$ttid}_jd = 0;
\t\t\t{$ttid}_process()
\t\t\t\$('#{$ttid}').submit();
\t\t\t\$('#{$ttid}_loadpic').show();

\t\t\t\$('iframe[name="{$ttid}_if"]').unbind('load').load(function(){
\t\t\t\tif(!window.{$ttid}){
\t\t\t\t\t\$('#{$ttid}_loadpic').hide();
\t\t\t\t\t\$('#{$ttid}_bfb').html('');\t
\t\t\t\t\tif({$onfailure}){
\t\t\t\t\t\t{$onfailure}('网络连接超时或文件大小超出',\$('#ttid'),3,'{$ttid}');
\t\t\t\t\t\tclearTimeout(window.{$ttid}jdproc);\t\t\t\t\t\t
\t\t\t\t\t}
\t\t\t\t}
\t\t\t});
\t\t}
\t});

EOT;
        if (is_array($cutpic)) {
            $htm .= <<<EOT
\t\twindow.{$ttid}_picpos = {};
\t\twindow.{$ttid}_picpos.cw = {$cutwidth};
\t\twindow.{$ttid}_picpos.ch = {$cutheight};
\t\twindow.{$ttid}_picpos.ctbl = {$aspectRatio};
EOT;
        }
        $htm .= <<<EOT

});
function {$ttid}_process(){
\tif(window.{$ttid}_jd < 99){
\t\tvar nexttime = parseInt(Math.sqrt(window.{$ttid}_jd)*100)*2;
\t\twindow.{$ttid}_jd = window.{$ttid}_jd+1;
\t\t\$('#{$ttid}_bfb').html(window.{$ttid}_jd+'%');
\t\twindow.{$ttid}jdproc = setTimeout(function(){
\t\t\t{$ttid}_process();
\t\t},nexttime);
\t}else{
\t\t\$('#{$ttid}_bfb').html('');
\t\t\$('#{$ttid}_loadpic').hide();
\t\tif({$onfailure}){
\t\t\t{$onfailure}('网络连接超时或文件大小超出',\$('#ttid'),3,'{$ttid}');
\t\t}
\t}
}
function {$ttid}_success(url,key){
\t\$('#{$ttid}_del').show();
\twindow.{$ttid}_jd = 100;
\t\$('#{$ttid}_bfb').html('100%');
\t\$('#{$ttid}_loadpic').hide();
\tclearTimeout(window.{$ttid}jdproc);
\tvar oldkey = \$('#{$ttid}_text').val();
\tif(oldkey.indexOf('@-@')!=-1){
\t\tvar oldkey2 = oldkey.split('@-@');
\t\t\$('#{$ttid}_text').val(key+'@-@'+oldkey2[1]);
\t}else if(oldkey.indexOf('/')==0){
\t\t\$('#{$ttid}_text').val(key+'@-@'+oldkey);
\t}else{
\t\t\$('#{$ttid}_text').val(key);
\t}
EOT;
        //图片放置位置
        if ($picareaid != '') {
            $htm .= <<<EOT
\twindow.{$ttid}_upimg = \$('<img id="{$ttid}_realpic" src="'+url+'"/>');
\t\$('#{$picareaid}').html('').append(window.{$ttid}_upimg);
EOT;
        }
        //成功上传事件
        if ($onsuccess != 'false') {
            $htm .= <<<EOT
\tif({$onsuccess}){
\t\t{$onsuccess}(url,\$('#{$ttid}'),'{$ttid}');
\t}
EOT;
        }
        if ($picareaid != '') {
            //开启图片上传后剪裁
            if (is_array($cutpic)) {
                $htm .= <<<EOT
\twindow.{$ttid}_uppimg = \$('<img id="{$ttid}_realpic" style="position: absolute;left:-999999px;top:-999999px;max-width:999999px;max-height:999999px;" src="'+url+'"/>');
\t\$('body').append(window.{$ttid}_uppimg);
\tvar centerbtn = \$('<center><button style="{$buttonStyle}" class="{$buttonClass}">{$buttonText}</button></center>');
\t\$('#{$picareaid}').append(centerbtn);
\twindow.{$ttid}_picpos.key = key;
\tvar {$ttid}_savepos = function(c){
\t\tvar xbfb = window.{$ttid}_uppimg.width()/window.{$ttid}_upimg.width();
\t\tvar ybfb = window.{$ttid}_uppimg.height()/window.{$ttid}_upimg.height();
\t\twindow.{$ttid}_picpos.x = c.x*xbfb;
\t\twindow.{$ttid}_picpos.y = c.y*ybfb;
\t\twindow.{$ttid}_picpos.x2 = c.x2*xbfb;
\t\twindow.{$ttid}_picpos.y2 = c.y2*ybfb;
\t\twindow.{$ttid}_picpos.w = c.w*xbfb;
\t\twindow.{$ttid}_picpos.h = c.h*ybfb;
\t\tif(c.w < 20 || c.h < 20){
\t\t\treturn false;
\t\t}
\t\treturn true;
\t}
\t\$('#{$ttid}_text').attr('needjc','yes');
\twindow.{$ttid}_upimg.ready(function(){
\t\$('#{$ttid}_bfb').html('');
\t\$('#{$ttid}_name').html('');
\t\t\$('#{$ttid}_realpic').Jcrop({
\t\t\taspectRatio: window.{$ttid}_picpos.ctbl
\t\t},function(){window.{$ttid}_jcrop_api = this;});
\t});
\t
\tcenterbtn.find('button').click(function(){
\t\tif(!{$ttid}_savepos(window.{$ttid}_jcrop_api.tellScaled())){
\t\t\treturn;
\t\t}
EOT;
                //隐参添加
                $htm .= <<<EOT
\t\t\$(this).attr('disabled',true);
\t\t
\t\t_.ajax('{$surl}',window.{$ttid}_form.serialize()+'&'+\$.param(window.{$ttid}_picpos),function(m){
\t\t\tif(m!='no'){
\t\t\t\t\$('#{$ttid}_text').attr('needjc','no');
\t\t\t\twindow.{$ttid}_uppimg.remove();
\t\t\t\tvar thejchpic = \$('<img src="{$STA}'+m+'?'+Math.random()+'"/>');
\t\t\t\t\$('#{$picareaid}').html(thejchpic);
\t\t\t\tvar oldkey = \$('#{$ttid}_text').val();
\t\t\t\tif(oldkey.indexOf('@-@')!=-1){
\t\t\t\t\tvar oldkey2 = oldkey.split('@-@');
\t\t\t\t\t\$('#{$ttid}_text').val(m+'@-@'+oldkey2[1]);
\t\t\t\t}else if(oldkey.indexOf('/')==0){
\t\t\t\t\t\$('#{$ttid}_text').val(m+'@-@'+oldkey);
\t\t\t\t}else{
\t\t\t\t\t\$('#{$ttid}_text').val(m);
\t\t\t\t}
EOT;
                //成功剪裁事件
                if ($oncutsuccess != 'false') {
                    $htm .= <<<EOT
\tif({$oncutsuccess}){
\t\t{$oncutsuccess}('{$STA}'+m,\$('#{$ttid}'),'{$ttid}');
\t}
EOT;
                }
                $htm .= <<<EOT
\t\t\t}else{
\t\t\t\talert('System error');
\t\t\t}
\t\t});
\t\treturn false;
\t});
EOT;
            }
        }
        $htm .= <<<EOT
}
function {$ttid}_failure(size,type){
\tif({$onfailure}){
\t\tif(type==2){
\t\t\t{$onfailure}('文件大小为:'+size+'K,超出了{$size}K的限制,上传失败!',\$('#ttid'),2,'{$ttid}');
\t\t}else if(type==4){
\t\t\t{$onfailure}(size,\$('#ttid'),4,'{$ttid}');
\t\t}
\t\tclearTimeout(window.{$ttid}jdproc);
\t\t\$('#{$ttid}_bfb').html('');
\t\t\$('#{$ttid}_name').html('');
\t\t\$('#{$ttid}_loadpic').hide();
\t}
}
</script>
EOT;
        return $htm;
    }