首先,这篇文章是写给Z-Blog插件开发人员作为参考的,仅仅提供一种思路。
新版Z-Blog中的PluginS插件已经支持检测插件版本了,给插件的安装和升级带来了很多方便。但是插件升级的同时可能造成插件数据库已经配置文件的覆盖,也就是说,升级后你可能只拥有一个初始化的插件。
这里提供一个方案,由插件自己解决这个问题,下面是相册插件windsphoto的include.asp部分代码,发出来说明一下,供参考。
include.asp部分代码
'定义数据库路径
Const WP_DATA_PATH="data/12345.mdb"
'注册插件
Call RegisterPlugin("WindsPhoto","ActivePlugin_WindsPhoto")
'安装插件
Function InstallPlugin_WindsPhoto()
On Error Resume Next
Call SetBlogHint_Custom("? 提示:[WindsPhoto]已启用,现在进入初始化系统设置.")
Call WindsPhoto_Rebackup_Include()
Call WindsPhoto_Database_Rename()
Err.Clear
End Function
'首次安装数据库改名....
Function WindsPhoto_Database_Rename()
Dim fso, f, s, pathnew, ranNum
randomize
ranNum=int((99-10+1)*rnd+99)
pathnew=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum& ".mdb"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.fileexists(BlogPath & "/plugin/windsphoto/data/winds.mdb") Then
Set f = fso.GetFile(BlogPath & "plugin/windsphoto/"& WP_DATA_PATH)
f.name=pathnew
Set f = Nothing
Dim strContent,strWP_DATA_PATH
strContent=LoadFromFile(BlogPath & "/PLUGIN/WindsPhoto/include.asp","utf-8")
strWP_DATA_PATH="data/" & pathnew
Call SaveValueForSetting(strContent,True,"String","WP_DATA_PATH",strWP_DATA_PATH)
Call SaveToFile(BlogPath & "/PLUGIN/WindsPhoto/include.asp",strContent,"utf-8",False)
End If
Set fso=nothing
End Function
'还原备份设置
Function WindsPhoto_Rebackup_Include()
Dim strContent,fso
Set fso=server.createobject("Scripting.Filesystemobject")
If fso.fileexists(BlogPath & "/plugin/windsphoto/include.asp.bak") Then
strContent=LoadFromFile(BlogPath & "/plugin/windsphoto/include.asp.bak","utf-8")
Call SaveToFile(BlogPath & "/plugin/windsphoto/include.asp",strContent,"utf-8",True)
'删除初始数据库
Call DelSiteFile("/plugin/windsphoto/data/winds.mdb")
'跳转到插件设置
Response.Redirect "../plugin/windsphoto/admin_setting.asp"
End If
Set fso=nothing
End Function
继续阅读
近期评论