/** * 图片字段表单组合处理 * @param type $field 字段名 * @param type $value 字段内容 * @param type $fieldinfo 字段配置 * @return type */ function image($field, $value, $fieldinfo) { //错误提示 $errortips = $fieldinfo['errortips']; if ($fieldinfo['minlength']) { //验证规则 $this->formValidateRules['info[' . $field . ']'] = array("required" => true); //验证不通过提示 $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $fieldinfo['name'] . "不能为空!"); } $setting = unserialize($fieldinfo['setting']); $width = $setting['width'] ? $setting['width'] : 180; $html = ''; //图片裁减功能只在后台使用 if (defined('IN_ADMIN') && IN_ADMIN) { $html = " <input type=\"button\" class=\"btn\" onclick=\"crop_cut_" . $field . "(\$('#{$field}').val());return false;\" value=\"裁减图片\"> \n <input type=\"button\" class=\"btn\" onclick=\"\$('#" . $field . "_preview').attr('src','" . CONFIG_SITEURL_MODEL . "statics/images/icon/upload-pic.png');\$('#" . $field . "').val('');return false;\" value=\"取消图片\"><script type=\"text/javascript\">\n function crop_cut_" . $field . "(id){\n\tif ( id =='' || id == undefined ) { \n isalert('请先上传缩略图!');\n return false;\n }\n var catid = \$('input[name=\"info[catid]\"]').val();\n if(catid == '' ){\n isalert('请选择栏目ID!');\n return false;\n }\n Wind.use('artDialog','iframeTools',function(){\n art.dialog.open(GV.DIMAUB+'index.php?a=public_imagescrop&m=Content&g=Contents&catid='+catid+'&picurl='+encodeURIComponent(id)+'&input={$field}&preview=" . ($setting['show_type'] && defined('IN_ADMIN') ? $field . "_preview" : '') . "', {\n title:'裁减图片', \n id:'crop',\n ok: function () {\n var iframe = this.iframe.contentWindow;\n if (!iframe.document.body) {\n alert('iframe还没加载完毕呢');\n return false;\n }\n iframe.uploadfile();\n return false;\n },\n cancel: true\n });\n });\n };\n</script>"; } //模块 $module = in_array(GROUP_NAME, array("Contents", "contents")) ? 'Contents' : GROUP_NAME; //生成上传附件验证 $authkey = upload_key("1,{$setting['upload_allowext']},{$setting['isselectimage']},{$setting['images_width']},{$setting['images_height']},{$setting['watermark']}"); //图片模式 if ($setting['show_type']) { $preview_img = $value ? $value : CONFIG_SITEURL_MODEL . 'statics/images/icon/upload-pic.png'; return $str . "<div style=\"text-align: center;\"><input type='hidden' name='info[{$field}]' id='{$field}' value='{$value}'>\n\t\t\t<a href='javascript:void(0);' onclick=\"flashupload('{$field}_images', '附件上传','{$field}',thumb_images,'1,{$setting['upload_allowext']},{$setting['isselectimage']},{$setting['images_width']},{$setting['images_height']},{$setting['watermark']}','{$module}','{$this->catid}','{$authkey}');return false;\">\n\t\t\t<img src='{$preview_img}' id='{$field}_preview' width='135' height='113' style='cursor:hand' /></a>\n <br/> " . $html . "\n </div>"; } else { //文本框模式 return $str . "<input type='text' name='info[{$field}]' id='{$field}' value='{$value}' style='width:{$width}px;' class='input' /> <input type='button' class='button' onclick=\"flashupload('{$field}_images', '附件上传','{$field}',submit_images,'1,{$setting['upload_allowext']},{$setting['isselectimage']},{$setting['images_width']},{$setting['images_height']},{$setting['watermark']}','{$module}','{$this->catid}','{$authkey}')\"/ value='上传图片'>" . $html; } }
/** * swfupload上传附件 */ public function swfupload(){ $grouplist = getcache('grouplist','member'); if(isset($_POST['dosubmit'])){ if( $_POST['swf_auth_key'] != md5(pc_base::load_config('system','auth_key').$_POST['SWFUPLOADSESSID']) || ($_POST['isadmin']==0 && !$grouplist[$_POST['groupid']]['allowattachment'])) exit(); pc_base::load_sys_class('attachment','',0); $attachment = new attachment($_POST['module'],$_POST['catid'],$_POST['siteid']); $attachment->set_userid($_POST['userid']); $siteid = get_siteid(); $site_setting = get_site_setting($siteid); $site_allowext = $site_setting['upload_allowext']; $aids = $attachment->upload('Filedata',$site_allowext,'','',array($_POST['thumb_width'],$_POST['thumb_height']),$_POST['watermark_enable']); if($aids[0]) { $filename= (strtolower(CHARSET) != 'utf-8') ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : $attachment->uploadedfiles[0]['filename']; if($attachment->uploadedfiles[0]['isimage']) { echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$attachment->uploadedfiles[0]['isimage'].','.$filename; } else { $fileext = $attachment->uploadedfiles[0]['fileext']; if($fileext == 'zip' || $fileext == 'rar') $fileext = 'rar'; elseif($fileext == 'doc' || $fileext == 'docx') $fileext = 'doc'; elseif($fileext == 'xls' || $fileext == 'xlsx') $fileext = 'xls'; elseif($fileext == 'ppt' || $fileext == 'pptx') $fileext = 'ppt'; elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') $fileext = 'flv'; else $fileext = 'do'; echo $aids[0].','.$this->upload_url.$attachment->uploadedfiles[0]['filepath'].','.$fileext.','.$filename; } exit; } else { echo '0,'.$attachment->error(); exit; } } else { if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) showmessage(L('att_no_permission')); $args = $_GET['args']; $authkey = $_GET['authkey']; if(upload_key($args) != $authkey) showmessage(L('attachment_parameter_error')); extract(getswfinit($_GET['args'])); $siteid = $this->get_siteid(); $site_setting = get_site_setting($siteid); $file_size_limit = sizecount($site_setting['upload_maxsize']*1024); $att_not_used = param::get_cookie('att_json'); if(empty($att_not_used) || !isset($att_not_used)) $tab_status = ' class="on"'; if(!empty($att_not_used)) $div_status = ' hidden'; //获取临时未处理文件列表 $att = $this->att_not_used(); $userid_flash=sys_auth($this->userid, 'ENCODE'); include $this->admin_tpl('swfupload'); } }
/** * 单文件上传字段表单组合处理 * @param type $field 字段名 * @param type $value 字段内容 * @param type $fieldinfo 字段配置 * @return type */ function downfile($field, $value, $fieldinfo) { //错误提示 $errortips = $fieldinfo['errortips']; if ($fieldinfo['minlength']) { //验证规则 $this->formValidateRules['info[' . $field . ']'] = array("required" => true); //验证不通过提示 $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $fieldinfo['name'] . "不能为空!"); } //扩展配置 $setting = unserialize($fieldinfo['setting']); //表单长度 $width = $setting['width'] ? $setting['width'] : 300; //生成上传附件验证 //同时允许的上传个数, 允许上传的文件类型, 是否允许从已上传中选择 $authkey = upload_key("1,{$setting['upload_allowext']},{$setting['isselectimage']}"); //模块 $module = MODULE_NAME; //文本框模式 return "<input type='text' name='info[{$field}]' id='{$field}' value='{$value}' style='width:{$width}px;' class='input' /> <input type='button' class='button' onclick=\"flashupload('{$field}_downfile', '附件上传','{$field}',submit_attachment,'1,{$setting['upload_allowext']},{$setting['isselectimage']}','{$module}','{$this->catid}','{$authkey}')\"/ value='上传文件'>"; }
/** * 多图片字段类型表单组合处理 * @param type $field 字段名 * @param type $value 字段内容 * @param type $fieldinfo 字段值 * @return string */ function images($field, $value, $fieldinfo) { //错误提示 $errortips = $fieldinfo['errortips']; //长度 if ($fieldinfo['minlength']) { //验证规则 $this->formValidateRules['info[' . $field . ']'] = array("required" => true); //验证不通过提示 $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $fieldinfo['name'] . "不能为空!"); } //字段扩展配置 $setting = unserialize($fieldinfo['setting']); $list_str = ''; if ($value) { $value = unserialize(html_entity_decode($value, ENT_QUOTES)); if (is_array($value)) { foreach ($value as $_k => $_v) { $list_str .= "<div id='image_{$field}_{$_k}' style='padding:1px'><input type='text' name='{$field}_url[]' value='{$_v['url']}' style='width:310px;' ondblclick='image_priview(this.value);' class='input'> <input type='text' name='{$field}_alt[]' value='{$_v['alt']}' style='width:160px;' class='input'> <a href=\"javascript:remove_div('image_{$field}_{$_k}')\">移除</a></div>"; } } } else { $list_str .= "<center><div class='onShow' id='nameTip'>您最多每次可以同时上传 <font color='red'>{$setting['upload_number']}</font> 张</div></center>"; } $string = '<input name="info[' . $field . ']" type="hidden" value="1"> <fieldset class="blue pad-10"> <legend>图片列表</legend>'; $string .= $list_str; $string .= '<div id="' . $field . '" class="picList"></div> </fieldset> <div class="bk10"></div> '; //模块 $module = MODULE_NAME; //生成上传附件验证 $authkey = upload_key("{$setting['upload_number']},{$setting['upload_allowext']},{$setting['isselectimage']},,,{$setting['watermark']}"); $string .= $str . "<a herf='javascript:void(0);' onclick=\"javascript:flashupload('{$field}_images', '图片上传','{$field}',change_images,'{$setting['upload_number']},{$setting['upload_allowext']},{$setting['isselectimage']},,,{$setting['watermark']}','{$module}','{$this->catid}','{$authkey}')\" class=\"btn\"><span class=\"add\"></span>选择图片 </a>"; return $string; }
/** * * @param string $name 表单名称 * @param int $id 表单id * @param string $value 表单默认值 * @param string $moudle 模块名称 * @param int $catid 栏目id * @param int $size 表单大小 * @param string $class 表单风格 * @param string $ext 表单扩展属性 如果 js事件等 * @param string $alowexts 允许图片格式 * @param array $file_setting */ public static function upfiles($name, $id = '', $value = '', $moudle = '', $catid = '', $size = 50, $class = '', $ext = '', $alowexts = '', $file_setting = array()) { if (!$id) { $id = $name; } if (!$size) { $size = 50; } //图片属性 if (!empty($file_setting) && count($file_setting)) { $file_ext = $file_setting[0] . ',' . $file_setting[1]; } else { $file_ext = ','; } if (!$alowexts) { $alowexts = 'jpg|gif'; } if (!defined('UPFILES_INIT')) { $str = '<script type="text/javascript" src="' . CONFIG_SITEURL_MODEL . 'statics/js/content_addtop.js"></script>'; define('UPFILES_INIT', 1); } //1, 允许上传的文件类型, 是否允许从已上传中选择, 图片高度, 图片宽度,是否添加水印1是 $authkey = upload_key("1,{$alowexts},1,{$file_ext}"); return $str . "<input type=\"text\" name=\"{$name}\" id=\"{$id}\" value=\"{$value}\" size=\"{$size}\" class=\"{$class}\" {$ext}/> <input type=\"button\" class=\"button\" onclick=\"javascript:flashupload('{$id}_files', '附件上传','{$id}',submit_attachment,'1,{$alowexts},1,{$file_ext}','{$moudle}','{$catid}','{$authkey}')\"/ value=\"上传文件\">"; }
/** * * @param string $name 表单名称 * @param int $id 表单id * @param string $value 表单默认值 * @param string $moudle 模块名称 * @param int $catid 栏目id * @param int $size 表单大小 * @param string $class 表单风格 * @param string $ext 表单扩展属性 如果 js事件等 * @param string $alowexts 允许上传的文件格式 * @param array $file_setting */ public static function upfiles($name, $id = '', $value = '', $moudle = '', $catid = '', $size = 50, $class = '', $ext = '', $alowexts = '', $file_setting = array()) { if (!$id) { $id = $name; } if (!$size) { $size = 50; } if (!empty($file_setting) && count($file_setting)) { $file_ext = $file_setting[0] . ',' . $file_setting[1]; } else { $file_ext = ','; } if (!$alowexts) { $alowexts = 'rar|zip'; } if (!defined('IMAGES_INIT')) { $str = '<script type="text/javascript" src="' . JS_PATH . 'swfupload/swf2ckeditor.js"></script>'; define('IMAGES_INIT', 1); } $authkey = upload_key("1,{$alowexts},1,{$file_ext}"); return $str . "<input type=\"text\" name=\"{$name}\" id=\"{$id}\" value=\"{$value}\" size=\"{$size}\" class=\"{$class}\" {$ext}/> <input type=\"button\" class=\"button\" onclick=\"javascript:flashupload('{$id}_files', '" . L('attachmentupload') . "','{$id}',submit_attachment,'1,{$alowexts},1,{$file_ext}','{$moudle}','{$catid}','{$authkey}')\"/ value=\"" . L('filesupload') . "\">"; }
</script> <script type="text/javascript"> //编辑器路径定义 var editorURL = GV.DIMAUB; </script> <script type="text/javascript" src="<?php echo CONFIG_SITEURL_MODEL; ?> statics/js/ueditor/editor_config.js"></script> <script type="text/javascript" src="<?php echo CONFIG_SITEURL_MODEL; ?> statics/js/ueditor/editor_all_min.js"></script> <script type="text/javascript"> <?php $authkey = upload_key("10,,1,,,0"); ?> var editorcontent; UE.commands['attachments'] = { execCommand : function(cmd){ flashupload('flashupload', '附件上传','content',ueAttachment,'10,,1,,,0','Web','10','<?php echo $authkey; ?> '); }, queryCommandState : function(){ return this.highlight ? -1 :0; } }; var editor_config_content = { _catid:'10',
function images($field, $value, $fieldinfo) { extract($fieldinfo); $list_str = ''; if ($value) { $value = string2array(new_html_entity_decode($value)); if (is_array($value)) { foreach ($value as $_k => $_v) { $list_str .= "<li id='image{$_k}' style='padding:1px'><input type='text' name='{$field}_url[]' value='{$_v[url]}' style='width:310px;' ondblclick='image_priview(this.value);' class='input-text'> <input type='text' name='{$field}_alt[]' value='{$_v[alt]}' style='width:160px;' class='input-text'> <a href=\"javascript:remove_div('image{$_k}')\">" . L('remove') . "</a></li>"; } } } else { //$list_str .= "<input type='hidden' name='{$field}_url[]' value='0'>"; $list_str .= "<center><div class='onShow' id='nameTip'>" . L('max_upload_num') . " <font color='red'>{$upload_number}</font> " . L('zhang') . "</div></center>"; } $string = '<input name="info[' . $field . ']" type="hidden" value="1"> <fieldset class="blue pad-10"> <legend>' . L('picutre_list') . '</legend>'; $string .= $list_str; $string .= '<ul id="' . $field . '" class="picList"></ul> </fieldset> <div class="bk10"></div> '; if (!defined('IMAGES_INIT')) { $str = '<script type="text/javascript" src="statics/js/swfupload/swf2ckeditor.js"></script>'; define('IMAGES_INIT', 1); } else { $str = ''; } $authkey = upload_key("{$upload_number},{$upload_allowext},{$isselectimage}"); $string .= $str . "<div class='picBut cu'><a herf='javascript:void(0);' onclick=\"javascript:flashupload('{$field}_images', '" . L('attachment_upload') . "','{$field}',change_images,'{$upload_number},{$upload_allowext},{$isselectimage}','member','','{$authkey}')\"/> " . L('select_picture') . " </a></div>"; return $string; }
var charset = '<?php echo CHARSET?>'; var uploadurl = '<?php echo pc_base::load_config('system','upload_url')?>'; //--> </script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>content_addtop.js"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>colorpicker.js"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script> <form name="myform" id="myform" action="?m=special&c=content&a=edit&specialid=<?php echo $_GET['specialid']?>&id=<?php echo $_GET['id']?>" method="post" enctype="multipart/form-data"> <div class="addContent"> <div class="crumbs"><?php echo L('edit_pos_info')?></div> <div class="col-right"> <div class="col-1"> <div class="content pad-6"> <h6> <?php echo L('content_thumb')?></h6> <div class="upload-pic img-wrap"><div class="bk10"></div><input type="hidden" name="info[thumb]" value="<?php echo $info['thumb']?>" id="thumb"> <a href="javascript:;" onclick="javascript:flashupload('thumb_images', '<?php echo L('file_upload')?>','thumb',thumb_images,'1,jpg|jpeg|gif|bmp|png,300,300','content','39','<?php echo upload_key('1,jpg|jpeg|gif|bmp|png,300,300')?>')"><img src="<?php if($info['thumb']) { echo $info['thumb']; } else {?>statics/images/icon/upload-pic.png<?php }?>" id="thumb_preview" width="135" height="113" style="cursor:hand" /></a><input type="button" style="width: 66px;" class="button" onclick="crop_cut($('#thumb').val());return false;" value="<?php echo L('crop_thumb')?>"><script type="text/javascript">function crop_cut(id){ if (id=='') { alert('<?php echo L('please_upload_thumb')?>');return false;} window.top.art.dialog({title:'<?php echo L('crop_thumb')?>', id:'crop', iframe:'index.php?m=content&c=content&a=public_crop&module=ZLCMS&picurl='+encodeURIComponent(id)+'&input=thumb&preview=thumb_preview', width:'680px', height:'480px'}, function(){var d = window.top.art.dialog({id:'crop'}).data.iframe; d.uploadfile();return false;}, function(){window.top.art.dialog({id:'crop'}).close()}); };</script></div> <h6> <?php echo L('author')?></h6> <input type="text" name="data[author]" value="<?php echo $data['author']?>" size="30"> <h6> <?php echo L('islink')?></h6> <input type="text" name="linkurl" id="linkurl" value="<?php if($info['islink']) { echo $info['url']; }?>" size="30" maxlength="255"<?php if($info['islink']) {?> disabled<?php }?>> <input name="info[islink]" type="checkbox" id="islink" value="1"<?php if($info['islink']) {?> checked<?php }?> onclick="ruselinkurl();" > <font color="red"><?php echo L('islink')?></font> <h6> <?php echo L('inputtime')?></h6> <?php echo form::date('info[inputtime]', format::date($info['inputtime'], 1) , 1);?> <h6> <?php echo L('template_style')?></h6> <?php echo form::select($template_list, $data['style'], 'name="data[style]" id="style" onchange="load_file_list(this.value)"', L('please_select'))?> <h6> <?php echo L('show_template')?></h6> <span id="show_template"><?php echo '<script type="text/javascript">$.getJSON(\'?m=zl_admin&c=category&a=public_tpl_file_list&style='.$style.'&id='.$data['show_template'].'&module=special&templates=show&name=data\', function(data){$(\'#show_template\').html(data.show_template);});</script>'?></span> </div> </div> </div> <div class="col-auto">
/** * swfupload 上传 * 通过swf上传成功以后回调处理时会调用swfupload_json方法增加cookies! */ public function swfupload() { $Member_group = F("Member_group"); if (IS_POST) { if ($_POST['swf_auth_key'] != md5(C("AUTHCODE") . $_POST['SWFUPLOADSESSID'])) { exit("0,权限认证失败!"); } $isadmin = (int) $this->_post("isadmin"); //检查用户是否有上传权限 if ($isadmin == 0) { $Member_group = F("Member_group"); if ((int) $Member_group[$this->groupid]['allowattachment'] < 1) { exit("0,所在的用户组没有附件上传权限!"); } } $Callback = false; //用户ID $upuserid = (int) $this->_post("uid"); //取得栏目ID $catid = $this->_post("catid"); //取得模块名称 $module = strtolower($this->_post("module")); //上传处理类 $upload = new UploadFile(); $Attachment = service("Attachment", array("module" => $module, "catid" => $catid, "isadmin" => $isadmin)); $Attachment->set_userid($upuserid); //如果允许上传的文件类型为空,启用网站配置的 uploadallowext //允许上传的文件类型,直接使用网站配置的。20120708 if ($isadmin) { $allowExts = CONFIG_UPLOADALLOWEXT; } else { $allowExts = CONFIG_QTUPLOADALLOWEXT; } //设置上传类型 $upload->allowExts = explode("|", $allowExts); //设置上传大小 if ($isadmin) { $upload->maxSize = (int) CONFIG_UPLOADMAXSIZE * 1024; //单位字节 } else { //前台 $upload->maxSize = (int) CONFIG_QTUPLOADMAXSIZE * 1024; //单位字节 } //图片裁减相关设置,如果开启,将不保留原图 if ($this->_post("thumb_width") && $this->_post("thumb_height")) { $upload->thumb = true; $upload->thumbRemoveOrigin = true; } //是否添加水印 post:watermark_enable 等于1也需要加水印 if ((int) $this->_post('watermark_enable')) { $Callback = array(array("AttachmentsAction", "water"), array()); } //设置缩略图最大宽度 $upload->thumbMaxWidth = $this->_post("thumb_width"); //设置缩略图最大高度 $upload->thumbMaxHeight = $this->_post("thumb_height"); //上传目录 可以单独写个方法,根据栏目ID生成相对于栏目目录附件 $this->filepath = $upload->savePath = $Attachment->FilePath(); //开始上传 if ($upload->upload($Callback)) { //上传成功 $info = $upload->getUploadFileInfo(); //写入附件数据库信息 $status = $Attachment->FileData($info[0]); if ($status) { if (in_array($info[0]['extension'], array("jpg", "png", "jpeg", "gif"))) { // 附件ID 附件网站地址 图标(图片时为1) 文件名 echo "{$status}," . $Attachment->filehttp . ",1," . str_replace(array("\\", "/"), "", $info[0]['name']); exit; } else { $fileext = $info[0]['extension']; if ($fileext == 'zip' || $fileext == 'rar') { $fileext = 'rar'; } elseif ($fileext == 'doc' || $fileext == 'docx') { $fileext = 'doc'; } elseif ($fileext == 'xls' || $fileext == 'xlsx') { $fileext = 'xls'; } elseif ($fileext == 'ppt' || $fileext == 'pptx') { $fileext = 'ppt'; } elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') { $fileext = 'flv'; } else { $fileext = 'do'; } echo "{$status}," . $Attachment->filehttp . "," . $fileext . "," . str_replace(array("\\", "/"), "", $info[0]['name']); exit; } } else { //删除已经上传的图片,这里逻辑还要优化 @unlink($info[0]['savepath'] . $info[0]['savename']); exit("0,上传成功,但写库失败!"); } } else { //上传失败,返回错误 exit("0," . $upload->getErrorMsg()); } } else { //1,允许上传的文件类型,是否允许从已上传中选择,图片高度,图片高度,是否添加水印1是 $args = $this->_get('args'); $authkey = $this->_get('authkey'); $module = $this->_get("module"); if ($this->module_list[ucwords($module)]) { $this->module = strtolower($module); } if (empty($args) || upload_key($args) != $authkey) { $this->error("配置参数有误!"); } if (!$this->isadmin) { $Member_group = F("Member_group"); if ((int) $Member_group[$this->groupid]['allowattachment'] < 1) { $this->error("所在的用户组没有附件上传权限!"); } } $info = explode(",", $args); $this->catid = $this->_get('catid'); $att_not_used = cookie('att_json'); if (empty($att_not_used)) { $tab_status = ' class="on"'; } if (!empty($att_not_used)) { $div_status = ' hidden'; } //参数补充完整 if (empty($info[1])) { //如果允许上传的文件类型为空,启用网站配置的 uploadallowext if ($this->isadmin) { $info[1] = CONFIG_UPLOADALLOWEXT; } else { $info[1] = CONFIG_QTUPLOADALLOWEXT; } } //获取临时未处理的图片 $att = $this->att_not_used(); //var_dump($att);exit; $this->assign("initupload", initupload($this->module, $this->catid, $args, $this->upuserid, $this->groupid, $this->isadmin)); //上传格式显示 $this->assign("file_types", implode(",", explode("|", $info[1]))); $this->assign("file_size_limit", $this->isadmin ? CONFIG_UPLOADMAXSIZE : CONFIG_QTUPLOADMAXSIZE); $this->assign("file_upload_limit", (int) $info[0]); $this->assign("att", $att); $this->assign("tab_status", $tab_status); $this->assign("div_status", $div_status); $this->assign("att_not_used", $att_not_used); $this->assign("watermark_enable", (int) $info[5]); //是否添加水印 $group = defined('GROUP_NAME') ? GROUP_NAME . '/' : ''; $this->display(); } }
<?php defined('IN_ADMIN') or exit('No permission resources.'); //$show_header = $show_validator = $show_scroll = 1; $show_dialog = $show_header = 1; include $this->admin_tpl('header', 'admin'); $thisExt = isset($this->M['ext']) ? $this->M['ext'] : ''; $authkey = upload_key('1,' . $thisExt . ',1'); ?> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH; ?> formvalidator.js" charset="UTF-8"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH; ?> formvalidatorregex.js" charset="UTF-8"></script> <div class="subnav"> <div class="content-menu ib-a blue line-x"> <?php if (isset($big_menu)) { echo '<a class="add fb" href="' . $big_menu[0] . '"><em>' . $big_menu[1] . '</em></a> '; } ?> <?php echo admin::submenu($_GET['menuid'], $big_menu); ?> <span>|</span><a href="javascript:window.top.art.dialog({id:'setting',iframe:'?m=poster&c=space&a=setting', title:'<?php echo L('module_setting'); ?>
/** * 检查是否可以上传 * @param string $module 模块名 * @param type $args 上传参数 * @param type $authkey 验证参数 * @return boolean|string */ public function isUpload($module, $args, $authkey) { if (ucwords($module) == 'User' || ucwords($module) == 'Works' || ucwords($module) == 'System' || ucwords($module) == 'News' || ucwords($module) == 'Advert' || ucwords($module) == 'Worksimg') { $this->module = strtolower($module); } else { return false; } //验证参数是否合法 if (empty($args) || upload_key($args) != $authkey) { return false; } return true; }
/** * @param string $name 表单名称 * @param int $id 表单id * @param string $value 表单默认值 * @param string $moudle 模块名称 * @param int $catid 栏目id * @param int $size 表单大小 * @param string $class 表单风格 * @param string $ext 表单扩展属性 如果 js事件等 * @param string $alowexts 允许上传的文件格式 * @param array $file_setting */ public static function upfiles($name, $id = '', $value = '', $moudle = '', $catid = '', $size = 50, $class = '', $ext = '', $alowexts = '', $file_setting = array()) { if (!$id) { $id = $name; } if (!$size) { $size = 50; } if (!empty($file_setting) && count($file_setting)) { $file_ext = $file_setting[0] . ',' . $file_setting[1]; } else { $file_ext = ','; } if (!$alowexts) { $alowexts = 'rar|zip'; } $authkey = upload_key("1,{$alowexts},1,{$file_ext}"); return $str . "<input type=\"text\" name=\"{$name}\" id=\"{$id}\" value=\"{$value}\" size=\"{$size}\" class=\"{$class}\" {$ext}/> <input type=\"button\" class=\"button\" onclick=\"javascript:flashupload('{$id}_files', '附件上传','{$id}',submit_attachment,'1,{$alowexts},1,{$file_ext}','{$moudle}','{$catid}','{$authkey}')\"/ value=\"上传文件\">"; }
protected function isUpload($module, $args, $authkey) { //兼容 if ('content' == $module) { $module = 'contents'; } $Module_list = F("Module"); if ($Module_list[ucwords($module)]) { $this->module = strtolower($module); } else { return '该模块未安装,不允许上传!'; } //验证参数是否合法 if (empty($args) || upload_key($args) != $authkey) { return '参数非法!'; } //如果是前台上传,判断用户组权限 if ($this->isadmin == 0) { $Member_group = F("Member_group"); if ((int) $Member_group[$this->groupid]['allowattachment'] < 1) { return "所在的用户组没有附件上传权限!"; } } return true; }
<tr> <th width="100">广告有效期</th> <td> <input type="test" name="sta_date" class="input J_date date" value="{$sta_date}" >- <input type="test" name="end_date" class="input J_date date" value="{$end_date}"> </td> </tr> <tr> <th width="100">广告图片</th> <td> <?php $authkey = upload_key("1,jpg|jpeg|gif|png|bmp,1,,,1"); ?> <input type='hidden' name='thumb' id='thumb' value='{$ad_img}'> <a href='javascript:void(0);' onclick="flashupload('thumb_images', '附件上传','thumb',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','Web','10','{$authkey}');return false;"> <img src='{$ad_img}' id='thumb_preview' width='135' height='113' style='cursor:hand' /> </a> <br> <input type="button" value="裁减图片" onclick="crop_cut_thumb($('#thumb').val());return false;" class="btn"> <input type="button" value="取消图片" onclick="$('#thumb_preview').attr('src','__ROOT__/statics/images/icon/upload-pic.png');$('#thumb').val('');return false;" class="btn"> <script type="text/javascript"> function crop_cut_thumb(id){ if ( id =='' || id == undefined ) {
function yf_image_copy($name, $id = '', $value = '', $moudle = '', $alowexts = '', $thumb_ext = '', $thumb_setting = array(), $watermark_setting = 0) { if (!$alowexts) { $alowexts = 'jpg|jpeg|gif|bmp|png'; } $html = ''; //生成上传附件验证 $authkey = upload_key("1,{$alowexts},1,{$thumb_ext},{$watermark_setting}"); //图片模式 if (empty($value)) { $preview_img = CONFIG_SITEURL_MODEL . 'static/images/icon/upload-pic.png'; } else { $preview_img = $value; } $url = "/index.php?a=yf_sign&c=Files&m=Upload&args=" . "1,{$alowexts},1,{$thumb_ext},{$watermark_setting}" . "&module=" . $moudle . "&authkey=" . $authkey; $html .= "<img src='{$preview_img}' class='yf_insert_copy' data-url='{$url}' data-title='上传图片' style='cursor:hand' /><input type='hidden' name='image' value='{$value}'>"; return $html; }
public function init() { $show_header = $show_dialog = $show_pc_hash = ''; if (isset($_GET['catid']) && $_GET['catid'] && $this->categorys[$_GET['catid']]['siteid'] == $this->siteid) { $catid = $_GET['catid'] = intval($_GET['catid']); $category = $this->categorys[$catid]; $modelid = $category['modelid']; $model_arr = getcache('model', 'commons'); $MODEL = $model_arr[$modelid]; unset($model_arr); $admin_username = param::get_cookie('admin_username'); //查询当前的工作流 $setting = string2array($category['setting']); $workflowid = $setting['workflowid']; $workflows = getcache('workflow_' . $this->siteid, 'commons'); $workflows = $workflows[$workflowid]; $workflows_setting = string2array($workflows['setting']); //将有权限的级别放到新数组中 $admin_privs = array(); foreach ($workflows_setting as $_k => $_v) { if (empty($_v)) { continue; } foreach ($_v as $_value) { if ($_value == $admin_username) { $admin_privs[$_k] = $_k; } } } //工作流审核级别 $workflow_steps = $workflows['steps']; $workflow_menu = ''; $steps = isset($_GET['steps']) ? intval($_GET['steps']) : 0; //工作流权限判断 if ($_SESSION['roleid'] != 1 && $steps && !in_array($steps, $admin_privs)) { showmessage(L('permission_to_operate')); } $this->db->set_model($modelid); if ($this->db->table_name == $this->db->db_tablepre) { showmessage(L('model_table_not_exists')); } $status = $steps ? $steps : 99; if (isset($_GET['reject'])) { $status = 0; } $where = 'catid=' . $catid . ' AND status=' . $status; //搜索 if (isset($_GET['start_time']) && $_GET['start_time']) { $start_time = strtotime($_GET['start_time']); $where .= " AND `inputtime` > '{$start_time}'"; } if (isset($_GET['end_time']) && $_GET['end_time']) { $end_time = strtotime($_GET['end_time']); $where .= " AND `inputtime` < '{$end_time}'"; } if ($start_time > $end_time) { showmessage(L('starttime_than_endtime')); } if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { $type_array = array('title', 'description', 'username'); $searchtype = intval($_GET['searchtype']); if ($searchtype < 3) { $searchtype = $type_array[$searchtype]; $keyword = strip_tags(trim($_GET['keyword'])); $where .= " AND `{$searchtype}` like '%{$keyword}%'"; } elseif ($searchtype == 3) { $keyword = intval($_GET['keyword']); $where .= " AND `id`='{$keyword}'"; } } if (isset($_GET['posids']) && !empty($_GET['posids'])) { $posids = $_GET['posids'] == 1 ? intval($_GET['posids']) : 0; $where .= " AND `posids` = '{$posids}'"; } $datas = $this->db->listinfo($where, 'id desc', $_GET['page']); $pages = $this->db->pages; $pc_hash = $_SESSION['pc_hash']; for ($i = 1; $i <= $workflow_steps; $i++) { if ($_SESSION['roleid'] != 1 && !in_array($i, $admin_privs)) { continue; } $current = $steps == $i ? 'class=on' : ''; $r = $this->db->get_one(array('catid' => $catid, 'status' => $i)); $newimg = $r ? '<img src="' . IMG_PATH . 'icon/new.png" style="padding-bottom:2px" onclick="window.location.href=\'?m=content&c=content&a=&menuid=' . $_GET['menuid'] . '&catid=' . $catid . '&steps=' . $i . '&pc_hash=' . $pc_hash . '\'">' : ''; $workflow_menu .= '<a href="?m=content&c=content&a=&menuid=' . $_GET['menuid'] . '&catid=' . $catid . '&steps=' . $i . '&pc_hash=' . $pc_hash . '" ' . $current . ' ><em>' . L('workflow_' . $i) . $newimg . '</em></a><span>|</span>'; } if ($workflow_menu) { $current = isset($_GET['reject']) ? 'class=on' : ''; $workflow_menu .= '<a href="?m=content&c=content&a=&menuid=' . $_GET['menuid'] . '&catid=' . $catid . '&pc_hash=' . $pc_hash . '&reject=1" ' . $current . ' ><em>' . L('reject') . '</em></a><span>|</span>'; } //$ = 153fc6d28dda8ca94eaa3686c8eed857;获取模型的thumb字段配置信息 $model_fields = getcache('model_field_' . $modelid, 'model'); $setting = string2array($model_fields['thumb']['setting']); $args = '1,' . $setting['upload_allowext'] . ',' . $setting['isselectimage'] . ',' . $setting['images_width'] . ',' . $setting['images_height'] . ',' . $setting['watermark']; $authkey = upload_key($args); $template = $MODEL['admin_list_template'] ? $MODEL['admin_list_template'] : 'content_list'; include $this->admin_tpl($template); } else { include $this->admin_tpl('content_quick'); } }
function video($field, $value, $fieldinfo) { $value_data = ''; //获取flash上传属性 pc_base::load_app_class('ku6api', 'video', 0); $setting = getcache('video', 'video'); if (empty($setting)) { return L('please_input_video_setting'); } $ku6api = new ku6api($setting['sn'], $setting['skey']); $flash_info = $ku6api->flashuploadparam(); //获取上传的视频 $key = 0; $list_str = "<div style='padding:1px'><ul class=\"tbsa\" id=\"video_{$field}_list\">"; if ($value) { $video_content_db = pc_base::load_model('video_content_model'); $video_store_db = pc_base::load_model('video_store_model'); $videos = $video_content_db->select(array('contentid' => $this->id), 'videoid, listorder', '', '`listorder` ASC', '', 'videoid'); if (!empty($videos)) { $videoids = ''; foreach ($videos as $v) { $videoids .= $v['videoid'] . ','; } $videoids = substr($videoids, 0, -1); $result = $video_store_db->select("`videoid` IN({$videoids})", '`videoid`, `title`, `picpath`', '', '', '', 'videoid'); if (is_array($result)) { //首先对$result按照$videos的videoid排序 foreach ($videos as $_vid => $v) { $new_result[] = $result[$_vid]; } unset($result, $_vid, $v); foreach ($new_result as $_k => $r) { $key = $_k + 1; $picpath = $r['picpath'] ? $r['picpath'] : IMG_PATH . 'nopic.gif'; $list_str .= "<li class=\"ac\" id=\"video_{$field}_{$key}\"><div class=\"r1\"><img src=\"{$r['picpath']}\" onerror=\"" . IMG_PATH . "nopic.jpg\" width=\"132\" height=\"75\"><input type='text' name='{$field}_video[{$key}][title]' value='" . $r['title'] . "' class=\"input-text ipt_box\"><input type='hidden' name='{$field}_video[{$key}][videoid]' value='{$r[videoid]}'><div class=\"r2\"><span class=\"l\"><label>" . L('listorder') . "</label><input type='text' name='{$field}_video[{$key}][listorder]' value='" . $videos[$r['videoid']]['listorder'] . "' class=\"input-text\"></span><span class=\"r\"> <a href=\"javascript:remove_div('video_{$field}_{$key}')\">" . L('delete') . "</a></span></li>"; } } } } $list_str .= "</ul></div>"; $data = ''; if (!defined('SWFOBJECT_INIT')) { $data .= '<script type="text/javascript" src="' . JS_PATH . 'video/swfobject2.js"></script>'; $data .= '<script type="text/javascript" src="' . JS_PATH . 'video/vod2ckedit.js"></script>'; define('SWFOBJECT_INIT', 1); $data .= '<SCRIPT LANGUAGE="JavaScript"> <!-- var js4swf = { onInit: function(list) { // 初始化时调用, 若 list.length > 0 代表有可续传文件 // [{file}, {file}] if(list.length > 0) { var length = list.length-1; $("#list_name").html("' . L('file', '', 'video') . '"+list[length].name+"' . L('failed_uplaod_choose_again', '', 'video') . '"); } this.showMessage("init", list); }, onSelect: function(files) { // 选中文件后调用, 返回文件列表 // [{file}, {file}] this.showMessage("select", files); }, onSid: function(evt) { // 获得 sid 后返回, 更新 sid 用 (key, sid, name, type, size) $("#video_title").val(evt.name); var ku6vid = evt.vid; $.get(\'index.php\', {m:\'video\', c:\'vid\', a:\'check\', vid:ku6vid}); this.showMessage("sid", evt); }, onStart: function() { // 开始上传 (选择文件后自动开始) this.showMessage("start"); }, onCancel: function() { // 上传取消事件 this.showMessage("cancel"); }, onProgress: function(evt) { // 上传进度事件 (bytesLoaded, bytesTotal, speed) m=1 时没有这事件 this.showMessage("progress", evt); }, onComplete: function(evt) { // 上传完成事件 (包含文件信息和完成后返回数据(data)) $("#vid").val(evt.vid); var video_num = parseInt($("#key").val()) + 1; var title = $("#video_title").val(); var vid = $("#vid").val(); var html = "<li id=\\"video_' . $field . '_"+video_num+"\\"><div class=\\"r1\\"><img src=\\"' . IMG_PATH . 'nopic.jpg\\" width=\\"132\\" height=\\"75\\"><input type=\\"text\\" name=\\"' . $field . '_video["+video_num+"][title]\\" value=\\""+title+"\\" class=\\"input-text\\"><input type=\\"hidden\\" name=\\"' . $field . '_video["+video_num+"][vid]\\" value=\\""+vid+"\\"><div class=\\"r2\\"><span class=\\"l\\"><label>' . L('listorder') . '</label><input type=\\"text\\" class=\\"input-text\\" name=\\"' . $field . '_video["+video_num+"][listorder]\\" value=\\""+video_num+"\\" ></span><span class=\\"r\\"> <a href=\\"javascript:remove_div(\'video_' . $field . '_"+video_num+"\')\\">' . L('delete') . '</a></span></li>"; $("#video_' . $field . '_list").append(html); $("#key").val(video_num); $("#video_title").val(""); swfobject.embedSWF("' . $flash_info['flashurl'] . '", "ku6uploader", "450", "45", "10.0.0", null, flashvars, params, attributes); //document.getElementById("frm").submit(); this.showMessage("complete", evt); }, onWarn: function(evt) { // 报错事件 (key, message) //this.showMessage("warn", evt); alert(evt.msg); }, showMessage: function() { console.log(arguments); } }; //--> </SCRIPT> <script type="text/javascript"> var flashvars = { m: "1", u: "' . $flash_info['userid'] . '", ctime: "' . $flash_info['passport_ctime'] . '", sig:"' . $flash_info['passport_sig'] . '", c: "vms", t: "1", n: "js4swf", k: "190000" ,ms:"39",s: "8000000"}; var params = { allowScriptAccess: "always" , wmode: "transparent"}; var attributes = { }; //swfobject.embedSWF("http://player.ku6cdn.com/default/podcast/upload/201104261840/ku6uploader.swf", "ku6uploader", "450", "45", "10.0.0", null, flashvars, params, attributes); swfobject.embedSWF("' . $flash_info['flashurl'] . '", "ku6uploader", "450", "45", "10.0.0", null, flashvars, params, attributes); </script>'; } $authkey = upload_key("{$upload_number},{$upload_allowext},{$isselectimage}"); $video_store_sel = defined('IN_ADMIN') ? '<div class="picBut cu video_btn" style="float:right; margin-top:10px;"><a herf="javascript:void(0);" onclick="javascript:video_store_select(\'' . $field . '_videoes\', \'' . L('choose_videoes') . '\',\'video_' . $field . '_list\',change_videoes, \'' . $_GET['pc_hash'] . '\')"> ' . L('videoes_store') . ' </a></div>' : ''; $vms_str = $flash_info['allow_upload_to_vms'] ? '<label class="ib cu" style="width:125px"><input type="radio" name="channelid" value="2">' . L('upload_to_ku6vms', '', 'video') . ' </label>' : ''; return $data . '<input name="info[' . $field . ']" type="hidden" value="1"><input type="hidden" id="key" value="' . $key . '"><fieldset class="blue pad-10"> <legend>' . L('videoes_lists') . '</legend><center><div class="onShow" id="nameTip">' . L('videoes_num') . '</center><div id="videoes" class="picList">' . $list_str . '</div> </fieldset> <table width="100%" border="0" cellspacing="1" class="tbb"> <tbody><tr> <td width="15%" height="40">' . L('select_upload_channel', '', 'video') . '</td> <td height="40"><label class="ib cu" style="width:125px"><input type="radio" name="channelid" value="1" checked> ' . L('upload_to_ku6') . ' </label>' . $vms_str . ' </td> </tr> <tr> <td width="15%" height="40"><div align="right" ><input class="input_style" type="text" value="' . L('video_title', '', 'video') . '" name="video_title" id="video_title" size="10"></div></td> <td height="40"> ' . $video_store_sel . ' <div id="ku6uploader"></div><BR><span id="list_name" style="color:red"></span></td><input type="hidden" id="vid" name="vid" value=""> </tr> </tbody></table>'; }
/** * swfupload上传附件 */ public function swfupload() { $grouplist = S('member/grouplist'); if (isset($_POST['dosubmit'])) { if ($_POST['swf_auth_key'] != md5(C('config', 'auth_key') . $_POST['SWFUPLOADSESSID']) || $_POST['isadmin'] == 0 && !$grouplist[$_POST['groupid']]['allowattachment']) { exit; } $catid = isset($_POST['catid']) ? intval($_POST['catid']) : 0; $attachment = new Attachment($_POST['application'], $catid); $attachment->set_userid($_POST['userid']); $aids = $attachment->upload('Filedata', $_POST['filetype_post'], '', '', array($_POST['thumb_width'], $_POST['thumb_height']), $_POST['watermark_enable']); if ($aids[0]) { $filename = strtolower(CHARSET) != 'utf-8' ? iconv('gbk', 'utf-8', $attachment->uploadedfiles[0]['filename']) : ''; if ($attachment->uploadedfiles[0]['isimage']) { echo $aids[0] . ',' . $this->upload_url . $attachment->uploadedfiles[0]['filepath'] . ',' . $attachment->uploadedfiles[0]['isimage'] . ',' . $filename; } else { $fileext = $attachment->uploadedfiles[0]['fileext']; if ($fileext == 'zip' || $fileext == 'rar') { $fileext = 'rar'; } elseif ($fileext == 'doc' || $fileext == 'docx') { $fileext = 'doc'; } elseif ($fileext == 'xls' || $fileext == 'xlsx') { $fileext = 'xls'; } elseif ($fileext == 'ppt' || $fileext == 'pptx') { $fileext = 'ppt'; } elseif ($fileext == 'flv' || $fileext == 'swf' || $fileext == 'rm' || $fileext == 'rmvb') { $fileext = 'flv'; } else { $fileext = 'do'; } echo $aids[0] . ',' . $this->upload_url . $attachment->uploadedfiles[0]['filepath'] . ',' . $fileext . ',' . $filename; } exit; } else { echo '0,' . $attachment->error(); exit; } } else { if ($this->isadmin == 0 && !$grouplist[$this->groupid]['allowattachment']) { showmessage(L('att_no_permission')); } $args = $_GET['args']; $authkey = $_GET['authkey']; if (upload_key($args) != $authkey) { showmessage(L('attachment_parameter_error')); } extract(getswfinit($_GET['args'])); $file_size_limit = byte_format(C('attachment', 'maxsize') * 1024); $att_not_used = cookie('att_json'); if (empty($att_not_used) || !isset($att_not_used)) { $tab_status = ' class="on"'; } if (!empty($att_not_used)) { $div_status = ' hidden'; } // 获取临时未处理文件列表 $att = $this->att_not_used(); include $this->view('swfupload'); } }
function downfiles($field, $value, $fieldinfo) { extract($fieldinfo); //错误提示 $errortips = $this->fields[$field]['errortips']; if ($minlength) { //验证规则 $this->formValidateRules['info[' . $field . ']'] = array("required" => true); //验证不通过提示 $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $name . "不能为空!"); } extract(unserialize($fieldinfo['setting'])); $list_str = ''; if ($value) { $value = unserialize(html_entity_decode($value, ENT_QUOTES)); if (defined("IN_ADMIN") && IN_ADMIN) { import("Form"); $Member_group = F("Member_group"); foreach ($Member_group as $v) { if (in_array($v['groupid'], array("1", "7", "8"))) { continue; } $group[$v['groupid']] = $v['name']; } } if (is_array($value)) { foreach ($value as $_k => $_v) { if (defined("IN_ADMIN") && IN_ADMIN) { $list_str .= "<div id='multifile{$_k}'><input type='text' name='{$field}_fileurl[]' value='{$_v[fileurl]}' style='width:310px;' class='input'> <input type='text' name='{$field}_filename[]' value='{$_v[filename]}' style='width:160px;' class='input'> 权限:" . Form::select($group, $_v['groupid'], 'name="' . $field . '_groupid[]"', '游客') . " 点数:<input type='text' name='{$field}_point[]' value='" . $_v['point'] . "' style='width:60px;' class='input'> <a href=\"javascript:remove_div('multifile{$_k}')\">移除</a></div>"; } else { $list_str .= "<div id='multifile{$_k}'><input type='text' name='{$field}_fileurl[]' value='{$_v[fileurl]}' style='width:310px;' class='input'> <input type='text' name='{$field}_filename[]' value='{$_v[filename]}' style='width:160px;' class='input'> <a href=\"javascript:remove_div('multifile{$_k}')\">移除</a></div>"; } } } } $string = '<input name="info[' . $field . ']" type="hidden" value="1"> <fieldset class="blue pad-10"> <legend>文件列表</legend>'; $string .= $list_str; $string .= '<ul id="' . $field . '" class="picList"></ul> </fieldset> <div class="bk10"></div> '; //生成上传附件验证 $authkey = upload_key("{$upload_number},{$upload_allowext},{$isselectimage}"); //后台允许权限设置 if (defined("IN_ADMIN") && IN_ADMIN) { import("Form"); $Member_group = F("Member_group"); foreach ($Member_group as $v) { if (in_array($v['groupid'], array("1", "7", "8"))) { continue; } $group[$v['groupid']] = $v['name']; } $js = '<script type="text/javascript"> function change_multifile_admin(uploadid, returnid) { var d = uploadid.iframe.contentWindow; var in_content = d.$("#att-status").html().substring(1); var in_filename = d.$("#att-name").html().substring(1); var str = \'\'; var contents = in_content.split(\'|\'); var filenames = in_filename.split(\'|\'); var group = \'权限:' . Form::select($group, $id, 'name="\' + returnid + \'_groupid[]"', '游客') . '\'; $(\'#\' + returnid + \'_tips\').css(\'display\', \'none\'); if (contents == \'\') return true; $.each(contents, function (i, n) { var ids = parseInt(Math.random() * 10000 + 10 * i); var filename = filenames[i].substr(0, filenames[i].indexOf(\'.\')); str += "<li id=\'multifile" + ids + "\'><input type=\'text\' name=\'" + returnid + "_fileurl[]\' value=\'" + n + "\' style=\'width:310px;\' class=\'input\'> <input type=\'text\' name=\'" + returnid + "_filename[]\' value=\'" + filename + "\' style=\'width:160px;\' class=\'input\' onfocus=\\"if(this.value == this.defaultValue) this.value = \'\'\\" onblur=\\"if(this.value.replace(\' \',\'\') == \'\') this.value = this.defaultValue;\\"> "+group+" 点数:<input type=\'text\' name=\'" + returnid + "_point[]\' value=\'0\' style=\'width:60px;\' class=\'input\'> <a href=\\"javascript:remove_div(\'multifile" + ids + "\')\\">移除</a> </li>"; }); $(\'#\' + returnid).append(str); } function add_multifile_admin(returnid) { var ids = parseInt(Math.random() * 10000); var group = \'权限:' . Form::select($group, $id, 'name="\' + returnid + \'_groupid[]"', '游客') . '\'; var str = "<li id=\'multifile" + ids + "\'><input type=\'text\' name=\'" + returnid + "_fileurl[]\' value=\'\' style=\'width:310px;\' class=\'input\'> <input type=\'text\' name=\'" + returnid + "_filename[]\' value=\'附件说明\' style=\'width:160px;\' class=\'input\'> "+group+" 点数:<input type=\'text\' name=\'" + returnid + "_point[]\' value=\'0\' style=\'width:60px;\' class=\'input\'> <a href=\\"javascript:remove_div(\'multifile" + ids + "\')\\">移除</a> </li>"; $(\'#\' + returnid).append(str); };</script>'; $string .= $str . "<a herf='javascript:void(0);' class=\"btn\" onclick=\"javascript:flashupload('{$field}_multifile', '附件上传','{$field}',change_multifile_admin,'{$upload_number},{$upload_allowext},{$isselectimage}','content','{$this->catid}','{$authkey}')\"><span class=\"add\"></span>多文件上传</a> <a class=\"btn\" herf='javascript:void(0);' onclick=\"add_multifile_admin('{$field}')\"><span class=\"add\"></span>添加远程地址</a>{$js}"; } else { $string .= $str . "<a herf='javascript:void(0);' class=\"btn\" onclick=\"javascript:flashupload('{$field}_multifile', '附件上传','{$field}',change_multifile,'{$upload_number},{$upload_allowext},{$isselectimage}','content','{$this->catid}','{$authkey}')\"><span class=\"add\"></span>多文件上传</a> <a herf='javascript:void(0);' class=\"btn\" onclick=\"add_multifile('{$field}')\"><span class=\"add\"></span>添加远程地址</a>"; } return $string; }
function downfiles($field, $value, $fieldinfo) { extract(string2array($fieldinfo['setting'])); $list_str = ''; if ($value) { $value = string2array(html_entity_decode($value, ENT_QUOTES)); if (is_array($value)) { foreach ($value as $_k => $_v) { $list_str .= "<div id='multifile{$_k}'><input type='text' name='{$field}_fileurl[]' value='{$_v[fileurl]}' style='width:310px;' class='input-text'> <input type='text' name='{$field}_filename[]' value='{$_v[filename]}' style='width:160px;' class='input-text'> <a href=\"javascript:remove_div('multifile{$_k}')\">" . L('remove_out') . "</a></div>"; } } } $string = '<input name="info[' . $field . ']" type="hidden" value="1"> <fieldset class="blue pad-10"> <legend>' . L('file_list') . '</legend>'; $string .= $list_str; $string .= '<ul id="' . $field . '" class="picList"></ul> </fieldset> <div class="bk10"></div> '; if (!defined('IMAGES_INIT')) { $str = '<script type="text/javascript" src="' . JS_PATH . 'swfupload/swf2ckeditor.js"></script>'; define('IMAGES_INIT', 1); } $authkey = upload_key("{$upload_number},{$upload_allowext},{$isselectimage}"); $string .= $str . "<input type=\"button\" class=\"button\" value=\"" . L('multiple_file_list') . "\" onclick=\"javascript:flashupload('{$field}_multifile', '" . L('attachment_upload') . "','{$field}',change_multifile,'{$upload_number},{$upload_allowext},{$isselectimage}','content','{$this->catid}','{$authkey}')\"/> <input type=\"button\" class=\"button\" value=\"" . L('add_remote_url') . "\" onclick=\"add_multifile('{$field}')\">"; return $string; }
public function video($field, $value, $fieldinfo) { extract($fieldinfo); $textheight = $textheight ? $textheight : 100; $list_str = ''; if ($value && !empty($value)) { $value = string2array(html_entity_decode($value, ENT_QUOTES)); if (is_array($value)) { foreach ($value as $_k => $_v) { $list_str .= "<li id='image{$_k}' style='padding:1px'><input type='text' name='{$field}_url[]' value='{$_v[url]}' style='width:310px;' ondblclick='image_priview(this.value);' class='input-text'> <input type='text' name='{$field}_alt[]' value='{$_v[alt]}' style='width:160px;' class='input-text'> <a href=\"javascript:remove_div('image{$_k}')\">" . L('remove_out', '', 'content') . "</a></li>"; } } } else { $list_str .= "<center><div class='onShow' id='nameTip'>" . L('upload_pic_max', '', 'content') . " <font color='red'>{$upload_number}</font> " . L('tips_pics', '', 'content') . "</div></center>"; } $list_str .= "<textarea style='width:98%;height:" . $textheight . "px;' name='" . $field . "'></textarea>"; $string = '<input name="info[' . $field . ']" type="hidden" value="1"> <fieldset class="blue pad-10"> <legend>' . $field . '列表</legend>'; $string .= $list_str; $string .= '<ul id="' . $field . '" class="picList"></ul> </fieldset> <div class="bk10"></div> '; if (!defined('IMAGES_INIT')) { $str = '<script type="text/javascript" src="statics/js/swfupload/swf2ckeditor.js"></script>'; define('IMAGES_INIT', 1); } $authkey = upload_key("{$upload_number},{$upload_allowext},{$isselectimage}"); $string .= $str . "<div class='picBut cu'><a herf='javascript:void(0);' onclick=\"javascript:flashupload('{$field}_images', '" . L('attachment_upload') . "','{$field}',change_images,'{$upload_number},{$upload_allowext},{$isselectimage}','content','{$this->catid}','{$authkey}')\"/> 选择" . $field . " </a></div>"; // add player $playerlists = array('0' => '请选择默认播放器'); $playerlist = S('common/player'); foreach ((array) $playerlist as $k => $v) { $playerlists[$v['playerid']] = $v['subject']; } $string .= Form::select($playerlists, $_v['p'] ? $_v['p'] : $defaultplayer, 'name="' . $field . '_defaultplayer"'); return $string; }
<?php defined('IN_ADMIN') or exit('No permission resources.'); //$show_header = $show_validator = $show_scroll = 1; $show_dialog = $show_header = 1; include $this->admin_tpl('header', 'admin'); $authkey = upload_key('1,' . $this->M['ext'] . ',1'); ?> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH; ?> formvalidator.js" charset="UTF-8"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH; ?> formvalidatorregex.js" charset="UTF-8"></script> <div class="subnav"> <div class="content-menu ib-a blue line-x"> <?php if (isset($big_menu)) { echo '<a class="add fb" href="' . $big_menu[0] . '"><em>' . $big_menu[1] . '</em></a>¡¡'; } ?> <?php echo admin::submenu($_GET['menuid'], $big_menu); ?> <span>|</span><a href="javascript:window.top.art.dialog({id:'setting',iframe:'?m=poster&c=space&a=setting', title:'<?php echo L('module_setting'); ?> ', width:'540', height:'320'}, function(){var d = window.top.art.dialog({id:'setting'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'setting'}).close()});void(0);"><em><?php
/** * 检查是否可以上传 * @param string $module 模块名 * @param type $args 上传参数 * @param type $authkey 验证参数 * @return boolean|string */ protected function isUpload($module, $args, $authkey) { $module_list = cache('Module'); if ($module_list[ucwords($module)] || ucwords($module) == 'Content') { $this->module = strtolower($module); } else { return false; } //验证参数是否合法 if (empty($args) || upload_key($args) != $authkey) { return false; } //如果是前台上传,判断用户组权限 if ($this->isadmin == 0) { $member_group = cache('Member_group'); if ((int) $member_group[$this->groupid]['allowattachment'] < 1) { return "所在的用户组没有附件上传权限!"; } } return true; }
<div class="col-right"> <div class="col-1"> <div class="content pad-6"> <h6> <?php echo L('content_thumb'); ?> </h6> <div class="upload-pic img-wrap"><div class="bk10"></div><input type="hidden" name="info[thumb]" value="<?php echo $info['thumb']; ?> " id="thumb"> <a href="javascript:;" onclick="javascript:flashupload('thumb_images', '<?php echo L('file_upload'); ?> ','thumb',thumb_images,'1,jpg|jpeg|gif|bmp|png,300,300','content','39','<?php echo upload_key('1,jpg|jpeg|gif|bmp|png,300,300'); ?> ')"><img src="<?php if ($info['thumb']) { echo $info['thumb']; } else { ?> statics/images/icon/upload-pic.png<?php } ?> " id="thumb_preview" width="135" height="113" style="cursor:hand" /></a><input type="button" style="width: 66px;" class="button" onclick="crop_cut($('#thumb').val());return false;" value="<?php echo L('crop_thumb'); ?> "><script type="text/javascript">function crop_cut(id){ if (id=='') { alert('<?php echo L('please_upload_thumb');
</div> </form> <script language="JavaScript" type="text/javascript"><!-- var j=<?php echo isset($total) ? $total : 0?>; function add_line() { for (var i=1; i<= $('#linenum').val(); i++) { $('#table_form').append('<tr><td><div class="contents" id="content_'+j+'"></div><div class="forms" style="display:block" id="form_'+j+'"><?php echo L('title')?>:<input type="text" id="title_'+j+'" name="title[]" class="input-text"> <?php echo L('link')?>:<input type="text" id="url_'+j+'" name="url[]" class="input-text"> <?php echo L('thumb')?>:<input type="hidden" name="thumb[]" id="thumb_'+j+'"> <a href="javascript:void(0)" onclick="flashupload(\'thumb_images\', \'<?php echo L('attachment_upload')?>\',\'thumb_'+j+'\',submit_images,\'1,jpg|jpeg|gif|bmp|png,1\',\'block\', \'\', \'<?php echo upload_key('1,jpg|jpeg|gif|bmp|png,1')?>\')"><?php echo L('pic_upload')?></a> <a href="javascript:void(0)" onclick="$(\'#thumb_'+j+'\').val(\'\')"><?php echo L('delete_image')?></a><br /><?php echo L('desc')?>:<textarea id="desc_'+j+'" name="desc[]" rows="10" cols="80"></textarea><br /> <input type="button" value="<?php echo L('submit')?>" class="button" onclick="form_submit('+j+')" /></div></td><td width="80"><a href="javascript:void(0);" class="arrowhead" onclick="moveUp(this);" title="<?php echo L('up')?>"></a><a href="javascript:void(0);" onclick="moveDown(this);" class="arrowhead-b" title="<?php echo L('down')?>"></a><a href="javascript:void(0)" onclick="edit_form('+j+')"><img src="<?php echo IMG_PATH?>icon/m_2.png" alt="<?php echo L('edit')?>" /></a><a href="javascript:void(0)" onclick="$(this).parent().parent().remove();" class="close" title="<?php echo L('delete')?>"></a></td></tr>'); j++; } } function insert_forms(obj) { eval("var d = "+obj+";"); $('#table_form').append('<tr><td><div class="contents" id="content_'+j+'"></div><div class="forms" style="display:block" id="form_'+j+'"><?php echo L('title')?>:<input type="text" id="title_'+j+'" name="title[]" class="input-text" value="'+d.title+'" > <?php echo L('link')?>:<input type="text" id="url_'+j+'" name="url[]" value="'+d.url+'" class="input-text"> <?php echo L('thumb')?>:<input type="hidden" name="thumb[]" value="'+d.thumb+'" id="thumb_'+j+'"> <a href="javascript:void(0)" onclick="flashupload(\'thumb_images\', \'<?php echo L('attachment_upload')?>\',\'thumb_'+j+'\',submit_images,\'1,jpg|jpeg|gif|bmp|png,1,200,200\',\'block\',\'\',\'<?php echo upload_key('1,jpg|jpeg|gif|bmp|png,1,200,200')?>\')"><?php echo L('pic_upload')?></a> <a href="javascript:void(0)" onclick="$(\'#thumb_'+j+'\').val(\'\')"><?php echo L('delete_image')?></a><br /><?php echo L('desc')?>:<textarea id="desc_'+j+'" name="desc[]" rows="10" cols="80">'+d.desc+'</textarea><br /> <input type="button" value="<?php echo L('submit')?>" class="button" onclick="form_submit('+j+')" /></div></td><td width="80"><a href="javascript:void(0);" class="arrowhead" onclick="moveUp(this);" title="<?php echo L('up')?>"></a><a href="javascript:void(0);" onclick="moveDown(this);" class="arrowhead-b" title="<?php echo L('down')?>"></a><a href="javascript:void(0)" onclick="edit_form('+j+')"><img src="<?php echo IMG_PATH?>icon/m_2.png" alt="<?php echo L('edit')?>" /></a><a href="javascript:void(0)" onclick="$(this).parent().parent().remove();" class="close" title="<?php echo L('delete')?>"></a></td></tr>'); form_submit(j); j++; } function block_view(id) { var old_action = $('#myform').attr('action'); $('#myform').attr('action', '?m=block&c=block_admin&a=public_view&id='+id); $('#myform').attr('target', 'view'); $('#myform').submit(); $('#myform').attr('action', old_action); $('#myform').attr('target', ''); } function showblock(id, html){ if (parent.right) {