<%on error resume next 'Get values member_id = request("aff_id") itype = request("type") id = request("id") iurl = request("go_url") itotal = replace(request("total"),"€","") itotal = replace(itotal,"$","") itotal = replace(itotal,"£","") total = cdbl(itotal) order_id = request("order_id") return = request("return") 'If url wrong then redirect if itype = "" then response.redirect replace(idigiaff_site_url,"affiliate.asp","index.asp") end if 'Get values for the images or text if id <> "" then open_recordset rs_images,"select * from images where id = "&id open_recordset rs_text_links,"select * from text_links where id = "&id end if 'If member wants to display an image in his website if itype = "get_img" then if not rs_images.eof then sql_insert = "update images set impressions = "&cint(rs_images("impressions"))+1&" where id = "&id conn.Execute(sql_insert) else open_recordset rs_images,"select * from images where active = -1 order by id" end if idigiaff_site_url = replace(idigiaff_site_url,"/affiliate.asp","") response.redirect idigiaff_site_url&"/images/"&rs_images("image") end if 'If member wants to display a text in his website if itype = "get_txt" then 'Update Statistics sql_insert = "update text_links set impressions = "&cint(rs_text_links("impressions"))+1&" where id = "&id conn.Execute(sql_insert) end if 'Does the user clicked from an image or a text? if itype = "img" or itype = "txt" then date_ip = dateadd("h",-iunique_clicks,now()) open_recordset rs_getIp,"select date_ip from ip where member_id = "&member_id&" and ip = '"&Request.ServerVariables("REMOTE_HOST")&"' and date_ip >= #"&date_ip&"# " 'Update Statistics if itype = "img" then if not rs_images.eof then sql_insert = "update images set clicks = "&cint(rs_images("clicks"))+1&" where id = "&id conn.Execute(sql_insert) else open_recordset rs_images,"select * from images where active = -1 order by id" end if else if not rs_text_links.eof then sql_insert = "update text_links set clicks = "&cint(rs_text_links("clicks"))+1&" where id = "&id conn.Execute(sql_insert) else open_recordset rs_text_links,"select * from text_links where active = -1 order by id" end if end if 'We create the cookie date_cookie = dateadd("d",icookie_expiration,now()) session("member_id") = member_id 'Does the user already clicked from the same ip? if rs_getIp.eof then sql_insert = "insert into ip (member_id,ip) values ("&member_id&",'"&Request.ServerVariables("REMOTE_HOST")&"')" conn.Execute(sql_insert) 'Do we accept payment per click? if iprogram = 2 or iprogram = 0 then if i2tiers = 1 then open_recordset rs_2tiers,"select second_tiers from members where id = "&member_id 'Do we accept second tier? if rs_2tiers("second_tiers") <> "" then 'Verif if second tier still exist open_recordset rs_verif,"select id from members where id = "&rs_2tiers("second_tiers") if not rs_verif.eof then sql_insert = "insert into input (member_id,status,type,imoney) values ("&rs_2tiers("second_tiers")&",1,2,"&iper_click_2tiers&")" conn.Execute(sql_insert) end if rs_verif.close set rs_verif = nothing end if rs_2tiers.close set rs_2tiers = nothing end if sql_insert = "insert into input (member_id,status,type,imoney) values ("&member_id&",1,0,"&iper_click&")" conn.Execute(sql_insert) end if end if 'Does the member want to redirect elsewhere? if iurl = "" then if itype = "img" then response.redirect rs_images("url") else response.redirect rs_text_links("url") end if else 'Does the member redirect in our web site? if instr(iurl,iweb_site_url) then response.redirect iurl else response.redirect iweb_site_url end if end if 'Close Connection rs_getIp.close set rs_getIp = nothing end if 'Does the user bought something? if itype = "sale" then 'Does the user have a cookie? if session("member_id") <> "" then 'Does we accept payment per sale? if iprogram = 2 or iprogram = 1 then 'Which amount have we to pay? if itype_commission = 0 then iamount_2tiers = iper_sale_2tiers iamount = iper_sale else iamount_2tiers = cdbl((iper_sale_2tiers * total) / 100) iamount = cdbl((iper_sale * total) / 100) end if 'Is it the first time we pass if session("already") = "" then 'Do we accept Second Tiers if i2tiers = 1 then open_recordset rs_2tiers,"select second_tiers from members where id = "&session("member_id") if rs_2tiers("second_tiers") <> "" then 'Verif if second tier still exist open_recordset rs_verif,"select id from members where id = "&rs_2tiers("second_tiers") if not rs_verif.eof then sql_insert = "insert into input (member_id,status,type,imoney,order_id) values ("&rs_2tiers("second_tiers")&",2,3,"&iamount_2tiers&",'"&order_id&"')" conn.Execute(sql_insert) end if rs_verif.close set rs_verif = nothing end if rs_2tiers.close set rs_2tiers = nothing end if sql_insert = "insert into input (member_id,status,type,imoney,order_id) values ("&session("member_id")&",2,1,"&iamount&",'"&order_id&"')" conn.Execute(sql_insert) session("already") = 1 end if end if end if if return = "1" then response.redirect iweb_site_url end if end if 'Is it a lead? if itype = "lead" then response.write session("member_id") 'Does the user have a cookie? if session("member_id") <> "" then 'Does we accept payment per leads? if iprogram = 2 or iprogram = 3 then 'Which amount have we to pay? iamount_2tiers = iper_lead_2tiers iamount = iper_lead 'Is it the first time we pass if session("already2") = "" then 'Do we accept Second Tiers if i2tiers = 1 then open_recordset rs_2tiers,"select second_tiers from members where id = "&session("member_id") if rs_2tiers("second_tiers") <> "" then 'Verif if second tier still exist open_recordset rs_verif,"select id from members where id = "&rs_2tiers("second_tiers") if not rs_verif.eof then sql_insert = "insert into input (member_id,status,type,imoney,order_id) values ("&rs_2tiers("second_tiers")&",1,4,"&iamount_2tiers&",'"&order_id&"')" conn.Execute(sql_insert) end if rs_verif.close set rs_verif = nothing end if rs_2tiers.close set rs_2tiers = nothing end if sql_insert = "insert into input (member_id,status,type,imoney,order_id) values ("&session("member_id")&",1,5,"&iamount&",'"&order_id&"')" conn.Execute(sql_insert) session("already2") = 1 end if end if end if end if 'If error then we redirect to the website if err then 'response.redirect iweb_site_url end if if id <> "" then rs_images.close rs_text_links.close set text_links = nothing set rs_images = nothing end if conn.close set conn = nothing%>