<?php
/*
乘风下载管理系统
作者QQ：178575
作者Email：yliangcf@163.com
作者网站：http://www.qqcf.com
详细简介：http://www.qqcf.com/cfdown.htm
上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
因为这些内容可能时常更新，就没有放在程序里，请自己上网站查看
*/
?>

<script>
function infoaddcheck(){
	
var assort = document.form_infoadd.assort.value;
var title = document.form_infoadd.title.value;
var downurl = document.form_infoadd.downurl.value;
var listid = document.form_infoadd.listid.value;

var infokeyword = document.form_infoadd.infokeyword.value;
var infodesc = document.form_infoadd.infodesc.value;
var infolabel = document.form_infoadd.infolabel.value;


if (assort==""){
 window.alert ('请选择分类!');
 document.form_infoadd.assort.focus();
 return false;
}

if(title==""){
 alert ('标题必须填写');
 document.form_infoadd.title.focus();
 return false;
}

if(downurl==""){
 alert ('下载地址必须填写');
 document.form_infoadd.downurl.focus();
 return false;
}

if(listid==""){
 alert ('置顶数字必须填写');
 document.form_infoadd.listid.focus();
 return false;
}

if(listid<0){
 alert ('置顶数字必须大于或等于0');
 document.form_infoadd.listid.focus();
 return false;
}

if (infokeyword!=""&&getByteLen(infokeyword)>255){
 alert ('允许最长字符数:255个,已输入字符数:'+getByteLen(infokeyword)+'个,输入过多请减少');
 document.form_infoadd.infokeyword.focus();
 return false;
}

if (infodesc!=""&&getByteLen(infodesc)>255){
 alert ('允许最长字符数:255个,已输入字符数:'+getByteLen(infodesc)+'个,输入过多请减少');
 document.form_infoadd.infodesc.focus();
 return false;
}

if (infolabel!=""&&getByteLen(infolabel)>255){
 alert ('允许最长字符数:255个,已输入字符数:'+getByteLen(infolabel)+'个,输入过多请减少');
 document.form_infoadd.infolabel.focus();
 return false;
}

return true;
}


function getByteLen(val) {
var len = 0;

for (var i = 0; i < val.length; i++) {
 var a = val.charAt(i);
 if (a.match(/[^\x00-\xff]/ig) != null){
  len += 2;
 }else{
  len += 1;
 }
}

return len;
}


var chars = ['0','1','2','3','4','5','6','7','8','9','a','b','d','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','D','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];

function generateMixed(n) {
     var res = "";
     for(var i = 0; i < n ; i ++) {
         var id = Math.ceil(Math.random()*61);
         res += chars[id];
     }
     return res;
}
</script>

<a href="<?php echo ChkStr($_SERVER["HTTP_REFERER"],1)?>" class="actionBtn" style="margin-top:10px;">返回列表</a>

  <form id="form_infoadd" name="form_infoadd" method="post" action="?action=infoaddsave&refurl=<?php echo urlencode($_SERVER["HTTP_REFERER"]);?>" onsubmit="return infoaddcheck()">
<table class="tb_1">
<tr class="tr_1"> 
<td colspan="2">添加下载</td>
</tr>
<tr>
  <td class="td_r">用户：</td>
  <td><select name="username" id="username">
<option selected value="">请选择用户</option>
<?php 
$Sql="Select username From cfdown_user where userstate=1 Order By id";
$Result2=mysql_query($Sql);
while($Rs2=mysql_fetch_assoc($Result2))
{
?>
<option value="<?php echo $Rs2["username"];?>"><?php echo $Rs2["username"];?></option>
<?php }?>
</select></td>
</tr>
<tr> 
          <td width="10%" class="td_r">分类：</td>
          <td><select name="assort" id="assort">
<option selected value="">请选择分类</option>
<?php 
$Sql="Select * From cfdown_infoclass Order By id";
$Result2=mysql_query($Sql);
while($Rs2=mysql_fetch_assoc($Result2))
{
?>
<option value="<?php echo $Rs2["id"];?>"><?php echo $Rs2["infoclassname"];?></option>
<?php }?>
</select>*必选项</td>
        </tr>
        <tr>
          <td class="td_r">标题：</td>
          <td><input name="title" type="text" id="title" size="82" />
            *必填项</td>
        </tr>
        <tr>
          <td class="td_r">大小：</td>
          <td><input name="filesize" type="text" id="filesize" size="20" />(K或M或G)</td>
        </tr>
        <tr>
          <td class="td_r">内容：</td>
          <td><input type="hidden" id="content" name="content" value="" style="display:none" />
            <input type="hidden" id="FCKeditor1___Config" value="" style="display:none" />
            <iframe id="FCKeditor1___Frame" src="../../js/FckEditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Default" width="530" height="350" frameborder="0" scrolling="no"></iframe></td>
        </tr>
        <tr>
          <td class="td_r">下载地址：</td>
          <td><input name="downurl" type="text" id="downurl" size="82" />*必填项</td>
        </tr>
        <tr>
        
<script>
$(function(){ 
 $("#downsite_0").click(function(){$("#t_downsite_0").show();$("#t_downsite_1").show();});
 $("#downsite_1").click(function(){$("#t_downsite_0").hide();$("#t_downsite_1").show();});
 
 $("#downsite_0").click();
});
</script>
          <td class="td_r">下载位置</td>
          <td>
        <input type="radio" name="downsite" value="0" id="downsite_0" checked="checked">
        外部服务器
		<input name="downsite" type="radio" id="downsite_1" value="1">
        内部服务器 </td>
        </tr>
        <tr id="t_downsite_0">
          <td class="td_r">外部下载密码：</td>
          <td><input name="outpwd" type="text" id="outpwd" value="" size="20" />不需密码下载请留空,这里是指下载地址为百度、蓝奏等类的下载地址如地址需要密码时填写在这里</td>
        </tr>
		
        <tr id="t_downsite_1">
          <td class="td_r">内部下载密码：</td>
          <td><input name="pwd" type="text" id="pwd" value="" size="20" />不需密码下载请留空，<a href="javascript:" onclick="document.getElementById('pwd').value=generateMixed(4);">点击这里取四位随机值</a>，这里是指打开本系统内这个下载的页面时需要的密码</td>
        </tr>

        <tr>
          <td class="td_r">置顶数字：</td>
          <td><input name="listid" type="text" id="listid" value="0" size="5" />
            *必填项(0不置顶，大于0则置顶且数字越大越在上，数字相同越晚发布越在上)</td>
        </tr>
        <tr class="tr_1">
          <td colspan="2">SEO信息</td>
        </tr>
        <tr>
          <td class="td_r">文章关键字：</td>
          <td><input name="infokeyword" type="text" id="infokeyword" size="82" /></td>
        </tr>
        <tr>
          <td class="td_r">文章描述：</td>
          <td><input name="infodesc" type="text" id="infodesc" size="82" /></td>
        </tr>
        <tr>
          <td class="td_r">文章标签：</td>
          <td><input name="infolabel" type="text" id="infolabel" size="82" /></td>
        </tr>
        <tr>
          <td></td>
          <td><input type="submit" name="Submit3322" value="增加" class="btn" id="infoadd" /></td>
        </tr>
      </table></form>
