<% set a_id "" set_form_variables 0 if {$a_id!=""} { set ip [ns_conn peeraddr] set db [ns_db gethandle] ns_db dml $db "begin transaction" set selection [ns_db 0or1row $db "select * from affiliate_ip_map where ip='$ip' and affiliate_id=$a_id"] if {$selection==""} { ns_db dml $db "insert into affiliate_ip_map (affiliate_id, last_hit, ip) values ($a_id, [ns_time], '$ip')" } else { ns_db dml $db "update affiliate_ip_map set last_hit=[ns_time] where affiliate_id=$a_id and ip='$ip'" } ns_db dml $db "end transaction" } %><% ns_returnredirect index.html %>