求助asp代码改写成php代码

<%

function delete_file(src)

set fso=server.createobject("scripting.filesystemobject")

if src<>"" then
myfile=server.mappath(src)

if fso.FileExists(myfile) then

fso.DeleteFile myfile

end if

end if

set fso=nothing

end function

kind=request.form("kind")

id=request.form("id")

select case kind

case "news"

sql="delete from news where id="&id

conn.execute(sql)

case "menu"

sql="delete from menu where id="&id

conn.execute(sql)

case "picnews"

    set rs=server.createobject("adodb.recordset")
    sql="select * from picnews where id="&id
    rs.open sql,conn,1,3
    src=rs("src")
    delete_file(src)
    rs.delete
    rs.update
    rs.close
    set rs=nothing

case "pic"

    set rs=server.createobject("adodb.recordset")
    sql="select * from picvideo where id="&id
    rs.open sql,conn,1,3
    src=rs("upfile")
    delete_file(src)
    rs.delete
    rs.update
    rs.close
    set rs=nothing

case "page"

    set rs=server.createobject("adodb.recordset")
    sql="select content from cont where id="&id
    rs.open sql,conn,1,3
    content=rs("content")
    set re=new regexp
    re.pattern="upload\/\d{17}\.\w{3,4}"
    re.global=true
    re.ignoreCase=true
    if re.Test(content) then
        set matches=re.execute(content)
        for each match in matches   
        filename=match.value
        delete_file(filename)
        '删除数据库中上传文件记录
        'conn.execute ("delete from uploadfile where filename='"&filename&"'")
        next
    end if
    set re=nothing
    rs.delete
    rs.update       
    rs.close
    set rs=nothing

end select

conn.close

set conn=nothing

response.write("ok")

%>

php
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问