<?php
if (!defined('ROOT'))
	exit ;
?>
<!DOCTYPE html>
<html>

	<head>
		<title>网盘设置</title>
		<meta name="description" content="">
		<meta name="keywords" content="">
		<?php
		include 'Inc_files.php';
		?>
		<style type="text/css">
		textarea{ text-indent: 0!important; padding-left: 5px!important;}
		.btn_indexbg_del{ cursor: pointer;}
		.help{ cursor: pointer;}
		.help_img{ max-width: 100%; display: none;}
		</style>
	</head>

	<body  data-type="index">
		<script src="<?php echo C('TMPL_PARSE_STRING.__TPL__'); ?>/assets/js/theme.js"></script>
		<div class="am-g tpl-g">
			<?php include 'Inc_head.php'?>
			<!-- 侧边导航栏 -->
			<?php
				include 'Inc_left.php';
			?>
			<!-- 内容区域 -->
			<div class="tpl-content-wrapper">
				<div class="row-content am-cf">
					<div class="row">
	                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
	                        <div class="widget am-cf">
	                            <div class="widget-head am-cf">
	                                <div class="widget-title am-fl">网盘设置</div>
	                            </div>
	                            <div class="widget-body am-fr">
	                                <form  class="am-form tpl-form-border-form tpl-form-border-br">
	                                	<input type="hidden" name="model_id" value="87" />
	                                	<input type="hidden" name="uid" value="<?php echo session('user_auth.id');?>" />
	                                	<input type="hidden" name="pk1" value="<?php echo session('user_auth.id');?>" />
	                                    
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">二级域名 </label>
                                          <div class="am-u-sm-9">
	                                        	<div style=" clear:both;">
	               <input type="text"  name="domain" style="width: 300px;float: left;" class="tpl-form-input domain" value="<?php echo $modval['domain'];?>" <?php if(!empty($modval['domain'])){echo 'disabled="disabled"';}?> ><div style="float: left;"><?php echo '.'.($modval['member_wangpan_type']>1?C('FUFEI_WANGPAN'):C('DOMAIN_WANGPAN'));?></div>
	                                        	</div>
                                          <small style=" clear:both; display: block;"> 自定义您网盘二级域名，确定后将永久使用不能修改（最低3个字符），如填写：106yunpan</small></div>
	                                    </div>
										
										<hr>

									<!--	<div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">网盘模板 </label>
	                                        <div class="am-u-sm-9">
												     <select name="tpl" data-am-selected="{searchBox: 0}" style="display: none;">
													<option value="sy106"  <?php if($modval['tpl']=='sy106'){echo 'selected="selected"';}?>>106简约样式</option>
													<option value="mulu" <?php if($modval['tpl']=='mulu'){echo 'selected="selected"';}?>>ys简约样式</option>	
													<option value="ay106"  <?php if($modval['tpl']=='ay106'){echo 'selected="selected"';}?>>106经典简约</option>												
													<option value="style01" <?php if($modval['tpl']=='style01'){echo 'selected="selected"';}?>>ys橙色样式</option>
													<option value="style05" <?php if($modval['tpl']=='style05'){echo 'selected="selected"';}?>>ys黑色样式</option>
													<option value="style06" <?php if($modval['tpl']=='style06'){echo 'selected="selected"';}?>>ys红色样式</option>
													<option value="style07" <?php if($modval['tpl']=='style07'){echo 'selected="selected"';}?>>ys黄金龙样式</option>
													<option value="style08" <?php if($modval['tpl']=='style08'){echo 'selected="selected"';}?>>ys灰色样式</option>
													<option value="style09" <?php if($modval['tpl']=='style09'){echo 'selected="selected"';}?>>ys蓝色样式</option>
													<option value="style10" <?php if($modval['tpl']=='style10'){echo 'selected="selected"';}?>>ys绿色样式</option>
													<option value="style18" <?php if($modval['tpl']=='style18'){echo 'selected="selected"';}?>>ys白色样式</option>
													<option value="style19" <?php if($modval['tpl']=='style19'){echo 'selected="selected"';}?>>黑色简约样式</option>
													<option value="style02" <?php if($modval['tpl']=='style02'){echo 'selected="selected"';}?>>ys发光标题（发光字）</option>
													<option value="style11" <?php if($modval['tpl']=='style11'){echo 'selected="selected"';}?>>ys黑灰样式（发光字）</option>
													<option value="style12" <?php if($modval['tpl']=='style12'){echo 'selected="selected"';}?>>ys黑色样式1（发光字）</option>
													<option value="style13" <?php if($modval['tpl']=='style13'){echo 'selected="selected"';}?>>ys黑色样式2（发光字）</option>
													<option value="style14" <?php if($modval['tpl']=='style14'){echo 'selected="selected"';}?>>ys红色样式（发光字）</option>
													<option value="style15" <?php if($modval['tpl']=='style15'){echo 'selected="selected"';}?>>ys黄金龙样式（发光字）</option>
													<option value="style16" <?php if($modval['tpl']=='style16'){echo 'selected="selected"';}?>>ys蓝色样式（发光字）</option>
													<option value="style17" <?php if($modval['tpl']=='style17'){echo 'selected="selected"';}?>>ys绿色样式（发光字）</option>
			
													
												</select>
	                                            <small>选择一个您喜欢的网盘模板</small>
	                                        </div>
	                                    </div>
																				
										<hr>-->
	
										<div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">网盘标题 </label>
	                                        <div class="am-u-sm-9">
	                                            <input type="text" name="seo_title" maxlength="100" style="width: 100%;" class="tpl-form-input" value="<?php echo $modval['seo_title'];?>">
												 <small>网盘标题限制100字符</a></small>	
	                                            <small></small>
	                                        </div>
	                                    </div> 
										
																				
										<hr>

	
										 <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">目录顺序 </label>
	                                        <div class="am-u-sm-9">
	                                            <select name="orderby" data-am-selected="{searchBox: 0}" style="display: none;">
													<option value="1"  <?php if($modval['orderby']==1){echo 'selected="selected"';}?>>按时间顺序</option>
													<option value="2" <?php if($modval['orderby']==2){echo 'selected="selected"';}?>>按标题顺序</option>
													<option value="3" <?php if($modval['orderby']==3){echo 'selected="selected"';}?>>按目录备注顺序</option>
												</select>
	                                            <small></small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
	                                    <?php if($modval['member_wangpan_type']>1){?>
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">是否显示文件下载次数 </label>
	                                        <div class="am-u-sm-9">
	                                            <select name="file_downloads_show" data-am-selected="{searchBox: 0}" style="display: none;">
													<option value="1"  <?php if($modval['file_downloads_show']==1){echo 'selected="selected"';}?>>显示</option>
													<option value="2" <?php if($modval['file_downloads_show']==2){echo 'selected="selected"';}?>>隐藏</option>
												</select>
	                                            <small></small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
	                                    <?php }?>
	                                    
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">提取码有效期 </label>
	                                        <div class="am-u-sm-9">
	                                        	<input type="number" style="width: 200px;" name="file_time" value="<?php echo empty($modval['file_time'])?24:$modval['file_time'];?>">
	                                            <small>填入数字，单位为小时</small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
										 <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">下载页防盗链</label>
	                                        <div class="am-u-sm-9">
	                                            <select name="dowloadurl_lock" data-am-selected="{searchBox: 0}">
													<option value="0" <?php if($modval['dowloadurl_lock']=='0'){echo 'selected="selected"';}?>>不启用</option>
													<option value="1" <?php if($modval['dowloadurl_lock']=='1'){echo 'selected="selected"';}?>>启用</option>
												</select>
	                                            <small style=" clear: both; display: block;">启用防盗链，下载页只能从网盘首页链接打开</small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
										 <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">公告滚动</label>
	                                        <div class="am-u-sm-9">
	                                            <select name="wpzs_gonggaogundong" data-am-selected="{searchBox: 0}" style="display: none;" placeholder="请选择">
	                                            	<option value=""></option>
													<option value="是"  <?php if($modval['wpzs_gonggaogundong']=='是'){echo 'selected="selected"';}?>>滚动</option>
													<option value="否" <?php if($modval['wpzs_gonggaogundong']=='否'){echo 'selected="selected"';}?>>不滚动</option>
												</select>
	                                            <small></small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">客服QQ </label>
                                          	<div class="am-u-sm-9">
	                                            <textarea name="service_qq" rows="5" style="width: 300px; text-indent: 0; padding-left: 5px;"><?php echo $modval['service_qq'];?></textarea>
                                              <small>自定义客服QQ：输入QQ号码，一行一个，格式为：QQ号|客服名称 也可以只填写QQ帐号，如：351075088|售后客服</small>	  
                                              <img class="help" src="<?php echo S('STATIC');?>/static/uhome/images/jiaocheng.png"/>
                                              <img class="help_img" src="<?php echo S('STATIC');?>/static/uhome/images/qqkefu.jpg"/>                                      
                                            </div>
	                                    </div>
										
																				
										<hr>

	
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">客服QQ群 </label>
                                          <div class="am-u-sm-9">
	                                            <textarea name="service_qq_group" rows="5" style=" text-indent: 0; padding-left: 5px;"><?php echo $modval['service_qq_group'];?></textarea>
                                              <small>输入QQ群链接，<a href="/v/show/model_id/39/id/12" target="_blank">如何获取QQ群链接教程 </a> 例如：https://jq.qq.com/?_wv=1027&k=5kY0cAG|106云盘（中间 “|”竖线隔开）</small>	 
                                              <img class="help" src="<?php echo S('STATIC');?>/static/uhome/images/jiaocheng.png"/>
                                              <img class="help_img" src="/static/uhome/images/QQqun.jpg?v=20180523"/>                                       </div>
	                                    </div> 
   										
										<hr>

	
	                             <!--     <?php if($modval['member_wangpan_type']>1){?>
	                                      <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">自定义代码 </label>
	                                        <div class="am-u-sm-9">
	                                             <textarea name="index_code" maxlength="500" rows="10" cols="5"><?php echo $modval['index_code']; ?> </textarea>
	                                            <small></small>
												<small> 部分模板支持：限制500字符，防止空间内挂马，空间不支持写入script和javascript和Stylesheet  权限支持106简约模板使用</a></small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
	                                    <?php }?>-->
										
	                                    <div class="am-form-group">
	                                        <label for="user-name" class="am-u-sm-3 am-form-label">网盘首页公告 </label>
	                                        <div class="am-u-sm-9">
	                                             <textarea name="gonggao" id="gonggao" rows="10" cols="5"><?php echo $modval['gonggao']; ?></textarea>
	                                            <small></small>
	                                        </div>
	                                    </div>
										
																				
										<hr>

	
                                 <div class="am-form-group">
	                                        <div class="am-u-sm-9 am-u-sm-push-3">
	                                            <button type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success btn_submit">
	                                            	提交
	                                            </button>
	                                        </div>
	                                    </div>
	                                </form>
	                            </div>
	                        </div>
	                    </div>
	                </div>
				</div>
			</div>
		</div>
		<?php
		include 'Inc_files_boot.php';
		?>
		<link rel="stylesheet" href="/static/public/kindeditor/default/default.css" />
		<script charset="utf-8" src="/static/public/kindeditor/kindeditor-min.js"></script>
		<script charset="utf-8" src="/static/public/kindeditor/zh_CN.js"></script>
		<script>
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create('#gonggao', {
					resizeType : 1,
					allowPreviewEmoticons : false,
					allowImageUpload : false,
					items : ['fontsize',  'forecolor', 'hilitecolor', 'bold','italic', 'underline', 'link']
				});
			});
			jQuery(document).ready(function($){ 
				try{
			        //传统表单提交同步
					jQuery('#gonggao').closest('form').submit(function(){
						editor.sync();
					});
					//ajax提交之前同步
					jQuery('.btn_submit').click(function(){
						editor.sync();
					});   
			    }catch(e){}
			    try{
			        jQuery(document).on('click','.btn_submit',function () {
			        	if (jQuery(".domain").val()=='') {
			        		wd_alert({msg:'域名不能为空'});
			        		return;
			        	}
			            var the=jQuery(this);
			            var url="<?php echo $modval['pk1']?'/x/mod':'/x/add';?>";
			            jQuery('[name="indexbg_time"]').val(new Date().getTime());
			            jQuery.ajax({
			            	url:url,
			                data:the.closest('form').serializeArray(),
			                dataType: "json",
			                type: "post",
			                timeout: 10000,
			                success: function(data) {
			                	if (data.status==1) {
			                		wd_alert({
			                			msg:'设置成功',
			                			timeout:1000,
			                			background:'#45B54A',
			                			color:'#fff'
			                		});
			                		jQuery(".domain").prop('disabled',true);
			                		
			                	}else{
			                		wd_alert({
			                			msg:data.info,
			                			timeout:1000,
			                			background:'#f00',
			                			color:'#fff'
			                		});
			                	}
			                },
			                error: function() {
			                    mui.toast("网络连接超时");
			                }
			            });          
			        })   
			    }catch(e){}
			});
			jQuery(document).on('click','.help',function () {
			    var the=jQuery(this);
			    the.next('.help_img').toggle();          
			})
			jQuery(document).on('blur','.domain',function () {
				var the=jQuery(this);
				the.val(the.val().toLowerCase());
			    jQuery.ajax({
			    	url:"/api/check_domain",
			        data:{
			        	domain:the.val()
			        },
			        dataType: "json",
			        type: "post",
			        timeout: 10000,
			        success: function(data) {
			        	if (the.next('small').html()!='此域名已占用') {
			        		localStorage.setItem('domain_msg',the.next('small').html());
			        	}
			        	if (data.status==0) {
			        		the.next('small').html('此域名已占用');
			        		the.val('');
			        		jQuery(".btn_submit").prop('disabled',true);
			        	}else{
			        		the.next('small').html(localStorage.getItem('domain_msg'));
			        		jQuery(".btn_submit").prop('disabled',false);
			        	}
			        },
			        error: function() {
			            mui.toast("网络连接超时");
			        }
			    });          
			});
			jQuery("textarea[maxlength]").each(function () {
				var the=jQuery(this);
				the.next('small').html(the.val().length + '/' + the.attr('maxlength'));
			});
			jQuery(document).on('keyup','textarea[maxlength]',function () {
			   	var the = jQuery(this);
				the.on('keyup', function() {
					the.next('small').html(the.val().length + '/' + the.attr('maxlength'));
				})           
			});
			//删除背景图片
			jQuery(document).on('click','.btn_indexbg_del',function () {
			    var the=jQuery(this);
			    the.prev('img').attr('src',the.data('defaultimg'));     
			    jQuery('[name="'+the.data('name')+'"]').val('');     
			})
			jQuery('[data-plupload]').each(function (index) {
				var the=jQuery(this);
				var opts = the.attr("data-plupload") ? the.attr("data-plupload") : "{}";
				opts = eval("(" + opts + ")");
				var the_id='btn'+index+new Date().getTime();
				the.attr('id',the_id);
				var browse_button=the_id;
				var runtimes=typeof(opts.runtimes)!="undefined"?opts.runtimes:'html5,flash,html4';
				var uptoken_url=opts.uptoken_url;
				var domain=typeof(opts.domain)!="undefined"?opts.domain:'http://www.qiniu.com';
				var get_new_uptoken=typeof(opts.get_new_uptoken)!="undefined"?opts.get_new_uptoken:false;
				var max_file_size=typeof(opts.max_file_size)!="undefined"?opts.max_file_size:'5mb';
				var flash_swf_url=typeof(opts.flash_swf_url)!="undefined"?opts.flash_swf_url:'js/plupload/Moxie.swf';
				var max_retries=typeof(opts.max_retries)!="undefined"?opts.max_retries:3;
				var chunk_size=typeof(opts.chunk_size)!="undefined"?opts.chunk_size:'4mb';
				var auto=typeof(opts.auto)!="undefined"?opts.auto:true;
				var multi=typeof(opts.multi)!="undefined"?opts.multi:false;
				var key=typeof(opts.key)!="undefined"?opts.key:false;
				if (key!==false) {
					var save_key=false;
				}
				var runtimes=typeof(opts.runtimes)!="undefined"?opts.runtimes:'html5,flash,html4';
				var runtimes=typeof(opts.runtimes)!="undefined"?opts.runtimes:'html5,flash,html4';
				var runtimes=typeof(opts.runtimes)!="undefined"?opts.runtimes:'html5,flash,html4';
				var runtimes=typeof(opts.runtimes)!="undefined"?opts.runtimes:'html5,flash,html4';
				new QiniuJsSDK().uploader({
					runtimes: runtimes, 
					browse_button: browse_button,
					uptoken_url:uptoken_url ,
					save_key: save_key,   // 默认 false。若在服务端生成uptoken的上传策略中指定了 `sava_key`，则开启，SDK会忽略对key的处理
					domain: domain, //bucket 域名，下载资源时用到，**必需**
					get_new_uptoken: get_new_uptoken, //设置上传文件的时候是否每次都重新获取新的token
					//container: 'container', //上传区域DOM ID，默认是browser_button的父元素，
					max_file_size: max_file_size, //最大文件体积限制
					flash_swf_url: flash_swf_url, //引入flash,相对路径
					max_retries: max_retries, //上传失败最大重试次数
					//dragdrop: true, //开启可拖曳上传
					//drop_element: 'container', //拖曳上传区域元素的ID，拖曳文件或文件夹后可触发上传
					chunk_size: chunk_size, //分块上传时，每片的体积
					auto_start: auto, //选择文件后自动上传，若关闭需要自己绑定事件触发上传,
					multi_selection:multi,
					init: {
						'FileFiltered':function(up, file) { //当文件添加到上传队列后
							if (typeof(opts.FileFiltered)=="function") {
								opts.FileFiltered(up, file);
							}else{
								if (multi===false) {
									var reader = new FileReader();
							        reader.readAsDataURL(file.getNative());
							        reader.onload = function(e){
							        	the.attr('src',this.result);
							        }
								}
							}
						},
						'FilesAdded': function(up, files) { //当文件添加到上传队列后
							if (typeof(opts.FilesAdded)=="function") {
								opts.FilesAdded(up, files);
							}
						},
						'BeforeUpload': function(up,file) { //当队列中的某一个文件正要开始上传前
							if (typeof(opts.BeforeUpload)=="function") {
								opts.BeforeUpload(up, file);
							}
						},
						'UploadProgress': function(up, file) { //会在文件上传过程中不断触发，可以用此事件来显示上传进度
							if (typeof(opts.UploadProgress)=="function") {
								opts.UploadProgress(up, file);
							}
						},
						'UploadComplete': function(up, file) { //当上传队列中所有文件都上传完成后触发
							if (typeof(opts.UploadComplete)=="function") {
								opts.UploadComplete(up, file);
							}
						},
						'FileUploaded': function(up, file, info) { //当队列中的某一个文件上传完成后触发
							if (typeof(opts.FileUploaded)=="function") {
								opts.FileUploaded(up, file, info);
							}else{
								info=JSON.parse(info.response);
								jQuery('[name="'+opts.url+'"]').val(info.key);
							}
						},
						'Error': function(up, err, errTip) { //当发生错误时触发监听
							if (typeof(opts.Error)=="function") {
								opts.Error(up, err, errTip);
							}
						},
						'Key': function(up, file) {
							return key;
			            }
					}
				});
			});
		</script>
		
</body>

</html>