Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
- <!-- #include file="../includes/pcweb.asp"-->
- <%
- ' This file is going to be filled to the brim with comments because the way we do single image
- ' pricing is MENTAL.
- Response.CacheControl = "no-cache"
- select case request("act")
- ' Change image to use gallery pricing/individual pricing
- case "change_pricing_type"
- ' get variables
- iid = request.form("iid")
- gid = request.form("gid")
- if ci(iid) <> 0 then
- if request.form("val") = "img" then
- ' Flag showing whether we are creating a new template.
- createNewFlag = 0
- ' Check if this image already has a pricing template
- set rshaspr = conn.execute("SELECT * FROM pricing WHERE iid=" & iid)
- if not rshaspr.eof then
- ' If so - set it's active to 1
- sql="UPDATE pricing SET active=1 WHERE iid=" & iid
- else
- ' Otherwise, create a new pricing template.
- sql="INSERT INTO pricing(active,template,pid,iid) VALUES (1,0,0," & iid & ")"
- createNewFlag = 1
- end if
- else
- sql="UPDATE pricing SET active=0 WHERE iid=" & iid
- end if
- conn.execute(sql)
- ' If we are creating a new template we have to copy all of the rows
- ' from the fields in the database which apply to the current
- ' image's parent gallery pricing template
- if createNewFlag = 1 then
- ' We need to copy the download settings from the parent gallery's template
- ' plan is to loop through the rows and insert them into downloads with the iid
- set rspd=conn.execute("SELECT * FROM downloads WHERE active=1 AND iid=0 AND pid=" & gid)
- if not rspd.eof then
- do while not rspd.eof
- sql="INSERT INTO downloads (active,price,isid,iid) VALUES (" &_
- "1," &_
- rspd("price") & "," &_
- rspd("isid") & "," &_
- iid &_
- ")"
- conn.execute(sql)
- rspd.movenext
- loop
- ' Kill rspd 'cuz we hate it
- set rspd = nothing
- end if
- end if
- ' After changing the pricing type - we want to rebuild the mental pricing form from the template
- ' First: Get the template
- sql = "SELECT * FROM pricing WHERE "
- if request.form("val") = "img" then
- sql = sql & "pid=" & gid
- else
- sql = sql & "iid=" & iid
- end if
- set rsp = conn.execute(sql)
- ' If the template exists, return the form.
- if not rsp.eof then
- ' First get current image info
- set rsi = conn.execute("SELECT * FROM images WHERE id=" & iid)
- ' Also get gallery info
- set rs = conn.execute("SELECT * FROM galleries WHERE id=" & gid)
- ' Get pricing-sizes
- set rsps=conn.execute("SELECT * FROM sizes WHERE active=1 AND pid=" & rsp("id"))
- end if
- end if
- case "blah"
- end select
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement