import java.awt.*; import java.io.*; import java.applet.*; import java.net.*; //import com.kcmultimedia.gifcanvas.; import com.kcmultimedia.gifcanvas.GIFCanvas; interface ClickListener { public void handleClick(); } class GIFCanvasPlus extends GIFCanvas { // Image buffer; //For double-buffered display. //Graphics og; //Graphics context for buffer. //boolean quit; //Thread killer ClickListener cl; //The ClickListener is notified when a mouseDown Event //occurs within the GIFCanvas. public GIFCanvasPlus(URL bg, ClickListener cl) throws Exception { super(bg); this.cl = cl; } public boolean mouseDown(Event e, int x, int y) { if(null != cl) cl.handleClick(); return true; } } public class vote extends Applet implements ClickListener,Runnable{ private String sitename, bandname, user, ref, ip; private boolean sitetick, bandtick = false; private boolean both = false; private String cgilog = "http://www.chartcentral.com/amc/vote/cgi/vote_in.pl"; private Color bgColor = new Color(200, 200, 255); private GIFCanvasPlus gif; private URL hyperlink; private Thread kicker; public void init() { // get the paramters user = ""; user = getParameter("ACCOUNT_NAME"); // get the names of the site, page and band sitename = getParameter("SITE_NAME"); if(sitename == "") sitename = "This Site"; bandname = getParameter("BAND_NAME"); if(bandname == "") bandname = "This Artist"; setLayout(new BorderLayout()); try{ URL animatedGIF = new URL(getCodeBase(), "../gif.pl/form_pics/" + user +".gif"); hyperlink = this.url(); gif = new GIFCanvasPlus(animatedGIF, this); }catch(Exception e){ System.out.println(e.toString()); return; } add("North",gif); } public void start() { if(null == kicker){ kicker = new Thread(this); kicker.start(); } } public void stop() { kicker=null; } public void run() { gif.start(); kicker=null; } public void destroy() { gif.stop(); } public URL url() throws Exception{ try{ ip = InetAddress.getLocalHost().toString(); } catch(Exception ex){ ip = ""; } // construct a URL to send back the the host using the GET method String ref = getDocumentBase().toString(); StringBuffer urlString = new StringBuffer(cgilog); urlString.append("?"); if(user != null) urlString.append("user=" + URLEncoder.encode(user) + "&"); urlString.append("referer=" + URLEncoder.encode(ref) + "&"); urlString.append("ip=" + URLEncoder.encode(ip) + "&"); urlString.append("method=vote"); if(sitename != null) urlString.append("site=" + URLEncoder.encode(sitename) + "&"); if(bandname != null) urlString.append("band=" + URLEncoder.encode(bandname) + "&"); urlString.append("sitechecked=1&"); urlString.append("bandchecked=1&"); return new URL(urlString.toString()); } public void handleClick() { getAppletContext().showDocument(hyperlink); } }