Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 2.69 KB | None | 0 0
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <!-- #include file="../includes/pcweb.asp"-->
  3. <%
  4. ' This file is going to be filled to the brim with comments because the way we do single image
  5. ' pricing is MENTAL.
  6.  
  7. Response.CacheControl = "no-cache"
  8. select case request("act")
  9.     ' Change image to use gallery pricing/individual pricing
  10.     case "change_pricing_type"
  11.         ' get variables
  12.         iid = request.form("iid")
  13.         gid = request.form("gid")
  14.        
  15.         if ci(iid) <> 0 then           
  16.             if request.form("val") = "img" then
  17.                 ' Flag showing whether we are creating a new template.
  18.                 createNewFlag = 0
  19.                 ' Check if this image already has a pricing template
  20.                 set rshaspr = conn.execute("SELECT * FROM pricing WHERE iid=" &  iid)
  21.                 if not rshaspr.eof then
  22.                     ' If so - set it's active to 1
  23.                     sql="UPDATE pricing SET active=1 WHERE iid=" & iid
  24.                 else
  25.                     ' Otherwise, create a new pricing template.
  26.                     sql="INSERT INTO pricing(active,template,pid,iid) VALUES (1,0,0," & iid & ")"
  27.                     createNewFlag = 1
  28.                 end if
  29.             else
  30.                 sql="UPDATE pricing SET active=0 WHERE iid=" & iid
  31.             end if
  32.             conn.execute(sql)
  33.            
  34.             ' If we are creating a new template we have to copy all of the rows
  35.             ' from the fields in the database which apply to the current
  36.             ' image's parent gallery pricing template
  37.             if createNewFlag = 1 then
  38.                 ' We need to copy the download settings from the parent gallery's template
  39.                 ' plan is to loop through the rows and insert them into downloads with the iid
  40.                 set rspd=conn.execute("SELECT * FROM downloads WHERE active=1 AND iid=0 AND pid=" & gid)
  41.                 if not rspd.eof then
  42.                     do while not rspd.eof
  43.                         sql="INSERT INTO downloads (active,price,isid,iid) VALUES (" &_
  44.                             "1," &_
  45.                             rspd("price") & "," &_
  46.                             rspd("isid") & "," &_
  47.                             iid &_
  48.                         ")"
  49.                         conn.execute(sql)
  50.                         rspd.movenext
  51.                     loop
  52.                     ' Kill rspd 'cuz we hate it
  53.                     set rspd = nothing
  54.                 end if
  55.             end if
  56.            
  57.             ' After changing the pricing type - we want to rebuild the mental pricing form from the template
  58.             ' First: Get the template
  59.             sql = "SELECT * FROM pricing WHERE "
  60.             if request.form("val") = "img" then
  61.                 sql = sql & "pid=" & gid
  62.             else
  63.                 sql = sql & "iid=" & iid
  64.             end if
  65.             set rsp = conn.execute(sql)
  66.            
  67.             ' If the template exists, return the form.
  68.             if not rsp.eof then
  69.                 ' First get current image info
  70.                 set rsi = conn.execute("SELECT * FROM images WHERE id=" & iid)
  71.                 ' Also get gallery info
  72.                 set rs = conn.execute("SELECT * FROM galleries WHERE id=" & gid)
  73.                 ' Get pricing-sizes
  74.                 set rsps=conn.execute("SELECT * FROM sizes WHERE active=1 AND pid=" & rsp("id"))               
  75.             end if
  76.         end if
  77.        
  78.     case "blah"
  79.            
  80. end select
  81. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement