SolveItproblems

SolveITProblems is a project of QFormat.net intellectual club

SolveITProblems это проект интеллектуального клуба QFormat.net

пятница, 4 июня 2010 г.

Dynamic IP vs Static IP

Problem:
When you have a static IP address it's very easy to remotely control you server, but if you haven't you can use software like TeamViewer. But if the upload speed from your server is very low, the only way to normally remote access is the Windows Remote Desktop service. So, what to do if you want to access server via RD but you haven't static IP. I've decided to write a software which will tell me the real IP address of the server at any time. Of course its simple, but i want to write program which will tech me new things :) .




Solution:
IP Shower. What technologies i used:
PHP, HTML, Java

Server side

7 php files on server
getip.php - Simply shows your ip using echo $_SERVER['REMOTE_ADDR'];
register.php - registers a new user
save.php - saves the get parameters from java program to a file
show.php - shows your ip by username and password registered from program
unregister.php - unregisters the user from system
additional.php - additional information in stie
index.php - simple shows form to login and download software

So now go to the Java side

Program sitting in system tray:

SystemTray st = SystemTray.getSystemTray();
PopupMenu menu = new PopupMenu("IP Shower");
MenuItem item1 = new MenuItem("Show Program");
menu.add(item1);
try {
File file = new File("icon.jpg");
Image image = ImageIO.read(file);

TrayIcon trayicon = new TrayIcon(image, "Shower", menu);

st.add(trayicon);
} catch (Exception e) {
System.out.println("Exception during addint trayicon to tray. " + e);
}

System Tray icon + Popup Menu is created

I need a task which will run periodically:

Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
public void run()
{
//What i want to be done!!!
}
},5*1000,5*60*1000);


To save information about registration on client i user seriliazable object, i save it like file it's easy and effective :)

you can enjoy it now here :)

Комментариев нет:

Отправить комментарий