%
Dim uSubject, uBody
setLocale server_locale
If request.querystring.count > 1 then
adID = CStr(request.querystring.item(1))
action = request.querystring.item(2)
Select Case action
Case "delete"
uID = Right(adID, 6)
If Not session("admin_loggedin" & strSUnique) = Session.SessionID And _
session("user_logged_moderator" & strSUnique) = False And _
Not CStr(session("user_logged_ID" & strSUnique)) = uID then Response.Redirect "default.asp"
strSQL = "SELECT " & tablPfx & "Ads.userID," & tablPfx & "Ads.catID," & tablPfx & "Ads.scatID," & tablPfx & "Ads.images," & tablPfx
strSQL = strSQL & "Ads.status," & tablPfx & "Ads.price," & tablUPfx & "User.ads," & tablUPfx & "User.credits," & tablPfx & "Ads.cat3rdID "
strSQL = strSQL & "FROM " & tablUPfx & "User," & tablPfx & "Ads WHERE (" & tablUPfx & "User.userID = " & tablPfx & "Ads.UserID AND "
strSQL = strSQL & tablPfx & "Ads.adID = '" & adID & "');"
set rs = objConn.Execute(strSQL)
If not rs.EOF then
img = rs(3)
userID = CLng(rs(0))
catID = CLng(rs(1))
scatID = CLng(rs(2))
cat3rdID = CLng(rs(8))
status = CLng(rs(4))
price = rs(5)
postedAds = CLng(rs(6))
ccredit = rs(7)
updateAds = postedAds - 1
If status = 0 and isnotfree then
currentCredit = CCur(FormatNumber(CCur(ccredit), 2))
adPrice = CCur(FormatNumber(CCur(price), 2))
updateCredit = currentCredit + adPrice
Else: updateCredit = 0
End If
Call updateUserPostData(userID, updateAds, updateCredit, "delete")
If status = 1 then UpdateList False, catID, scatID, cat3rdID
objConn.Execute("DELETE FROM " & tablPfx & "Ads WHERE adID = '" & adID & "';")
If isEvents then Call logEvent("Ad Deleted", adID, Empty, Empty, Empty, Empty)
If not img = Empty then
On Error Resume Next
imgArray = Split(img, sf)
For g = 0 to UBound(imgArray) - 1
delImg = uploadPATH & Split(imgArray(g), "|")(0)
objFile.DeleteFile(delImg)
Next
On Error Goto 0
End If
rs.close
On Error Resume Next
objFile.DeleteFile(server.mappath(ad_cache) & "\" & adID & ".htm")
On Error Goto 0
Application("cl_marquee" & strUnique) = Empty
If Len(CStr(session("user_logged_ID" & strSUnique))) > 0 then
set rs = objConn.Execute("SELECT credits,ads FROM " & tablUPfx & "User WHERE userID = " & CLng(session("user_logged_ID" & strSUnique)) & ";")
If not rs.EOF then
session("user_logged_credit" & strSUnique) = FormatNumber(CCur(rs("credits")), 2)
session("user_logged_ads" & strSUnique) = rs("ads")
End If
rs.close
End If
If Len(request("returnpage")) > 0 then Response.Redirect request("returnpage"): Else: Response.Redirect "default.asp"
Else
set rs = objConn.Execute("SELECT catID,scatID,status,images,cat3rdID FROM " & tablPfx & "Ads WHERE " & tablPfx & "Ads.adID = '" & adID & "';")
If rs.EOF then
Response.Write "
Invalid Request! Ad not found in database.
" & msgBack
Else
catID = rs(0)
scatID = rs(1)
cat3rdID = rs(4)
status = rs(2)
images = rs(3)
objConn.Execute("DELETE FROM " & tablPfx & "Ads WHERE adID = '" & adID & "';")
If isEvents then Call logEvent("Ad Deleted", adID, Empty, Empty, Empty, Empty)
If not img = Empty then
On Error Resume Next
imgArray = Split(img, sf)
For g = 0 to UBound(imgArray) - 1
delImg = uploadPATH & Split(imgArray(g), "|")(0)
objFile.DeleteFile(delImg)
Next
On Error Goto 0
End If
If status = 1 then UpdateList False, catID, scatID, cat3rdID
End If
rs.close
On Error Resume Next
objFile.DeleteFile(server.mappath(ad_cache) & "\" & adID & ".htm")
On Error Goto 0
Application("cl_marquee" & strUnique) = Empty
End If
Case "activate"
If Not session("admin_loggedin" & strSUnique) = Session.SessionID and session("user_logged_moderator" & strSUnique) = False then Response.Redirect "default.asp"
strSQL = "SELECT email," & tablPfx & "Ads.status," & tablPfx & "Ads.nick," & tablPfx & "Ads.userID,"
strSQL = strSQL & tablPfx & "Ads.catID," & tablPfx & "Ads.sCatID," & tablPfx
strSQL = strSQL & "Ads.pdate," & tablPfx & "Ads.edate, " & tablPfx & "Ads.subject, " & tablPfx & "Ads.body, " & tablPfx & "Ads.cat3rdID "
strSQL = strSQL & "FROM " & tablUPfx & "User," & tablPfx & "Ads WHERE (" & tablUPfx & "User.userID = " & tablPfx
strSQL = strSQL & "Ads.UserID AND " & tablPfx & "Ads.adID = '" & adID & "');"
set rs = objConn.Execute(strSQL)
sdd = dd(objConn)
If not rs.EOF then
uEmail = CryptText(rs(0), key, True)
uNick = rs(2)
userID = CLng(rs(3))
status = CLng(rs(1))
catID = CLng(rs(4))
subcatID = CLng(rs(5))
cat3rdID = CLng(rs(10))
pdate = CDate(rs(6))
edate = CDate(rs(7))
subject = rs(8)
body = rs(9)
duration = edate - pdate
duration = Round(duration)
edate = Now + duration
edate = ConvDate(edate)
iNow = ConvDate(Now)
If status = 0 then
set rs = Nothing
strSQL = "UPDATE " & tablPfx & "Ads SET status = 1, pdate = " & sdd & iNow & sdd & ", edate = " & sdd & edate & sdd & " WHERE adID = '" & adID & "';"
objConn.Execute(strSQL)
Call UpdateList(True, catID, subcatID, cat3rdID)
Call getTemplate("New_Ad_Approved", uEmail, Empty, uNick, Empty, adID)
Call sendEmail(uEmail, notify_email, uSubject, uBody)
Application("cl_marquee" & strUnique) = Empty
Call matchAlerts(adID, catID, subcatID, cat3rdID, subject, body)
Response.Redirect "viewad.asp?id=" & adID
If IsCache then session("cached" & strSUnique) = "yes"
Else: Response.Write "
Ad is already active or expired! Only pending ads can be activated!
" & msgBack
End If
Else: Response.Write "
Invalid Request! Ad not found in database.
" & msgBack
End If
rs.close
Case "duration"
If Not session("admin_loggedin" & strSUnique) = Session.SessionID and session("user_logged_moderator" & strSUnique) = False then Response.Redirect "default.asp"
processVal = CLng(Request.Querystring.Item(3))
If isNumeric(processVal) then
Set rsexp = objConn.Execute("SELECT edate FROM " & tablPfx & "Ads WHERE adID = '" & adID & "';")
If not rsexp.EOF then
postExpire = CDate(rsexp(0))
postExpire = DateAdd("d", processVal, postExpire)
postExpire = DateAdd("h", -timeOffset, postExpire)
postExpire = ConvDate(postExpire)
sdd = dd(objConn)
strSQL = "UPDATE " & tablPfx & "Ads SET edate = " & sdd & postExpire & sdd & " WHERE adID = '" & adID & "';"
objConn.Execute(strSQL)
If IsCache then session("cached" & strSUnique) = "yes"
End If
End If
Response.Redirect "viewad.asp?id=" & adID
End Select
Else: Response.Redirect "admin_logon.asp"
End If
%>