科讯博客中,如果会员过多的外链音乐,会造成网页刷新过慢而打不开网页
论坛有人提到这个问题,一生斑竹也给出了相应的解决办法,但是那个方法 有些错误,还是不能限制数量
我对源码做了分析,重新改写如下,经测试完全可以控制数量
注意:控制的数量请修改蓝色的数字即可
打开User_Music.asp文件,找到大约257行到264行
If ID=0 Then
Conn.Execute("Insert Into KS_BlogMusic(songname,url,singer,adddate,username) values('" & SongName & "','" & Url & "','" & Singer & "'," & SqlNowString & ",'" & KSUser.UserName &"')")
Response.Write "<script>if (!confirm('恭喜,歌曲添加成功!继续添加吗?')) parent.pop.reset(); else location.href='?action=addlink';</script>"
Else
Conn.Execute("Update KS_BlogMusic set songname='" & SongName & "',url='" & Url & "',singer='" & Singer & "' where username='" & KSUser.UserName & "' and id=" & ID)
Response.Write "<script>alert('恭喜,歌曲修改成功!'); parent.pop.reset();</script>"
End If
End Sub
把上面的代码替换为
If ID=0 Then
If conn.execute("select count(id) from ks_blogmusic where username='" & KSUser.UserName & "'")(0)>=3 then
Response.Write "<script>alert('抱歉,本博客只允许最多添加三首歌曲!');parent.pop.reset();</script>"
else
Conn.Execute("Insert Into KS_BlogMusic(songname,url,singer,adddate,username) values('" & SongName & "','" & Url & "','" & Singer & "'," & SqlNowString & ",'" & KSUser.UserName &"')")
Response.Write "<script>if (!confirm('恭喜,歌曲添加成功!继续添加吗?')) parent.pop.reset(); else location.href='?action=addlink';</script>"
end if
Else
Conn.Execute("Update KS_BlogMusic set songname='" & SongName & "',url='" & Url & "',singer='" & Singer & "' where username='" & KSUser.UserName & "' and id=" & ID)
Response.Write "<script>alert('恭喜,歌曲修改成功!'); parent.pop.reset();</script>"
End If
End Sub
如果会员添加的音乐大于3首,则会弹出警告提示框
![](/editor/ksplus/FileIcon/jpg.gif)
此主题相关图片如下:qq截图未命名.jpg
![qq截图未命名.jpg](/club/UploadFile/2009-8/2009811220151330.jpg)