ADSL搭建免费域名网站
来源:互联网 发布:java快速排序原理 编辑:程序博客网 时间:2024/06/08 05:33
使用ADSL上网的同学可以在家里建一个免费的网站了,不过速度可不敢恭维。
其实也就是获取外网IP,然后更新mycool.net的免费域名信息。这样,当你的ADSL断网后再重拨,获得的新IP能及时的更新到你的免费域名系统中。
需要上www.mycool.net申请一个免费域名,修改一下代码中用户名和密码,运行就OK了。
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.MessageFormat;
public final class Main ...{
private static String oldIP = "";
public static void main(String[] args) ...{
while(true) ...{
String ip = getWanIP();
if (!oldIP.equals(ip)) ...{
updateDomainInfo("yourname", "oldpass", "newpass", "yourmail.domain.com", ip);
oldIP = ip;
}
try ...{
Thread.sleep(1000*60);
} catch (InterruptedException e) ...{
e.printStackTrace();
}
}
}
private static String getWanIP() ...{
BufferedReader in = null;
try ...{
URL url = new URL("http://vip.cn99.com/ret.php");
in = new BufferedReader(new InputStreamReader(url.openStream()));
String str = in.readLine();
return str;
} catch (MalformedURLException e) ...{
} catch (IOException e) ...{
} finally ...{
if (in != null)
try ...{
in.close();
}catch(IOException e) ...{}
}
return null;
}
private static void updateDomainInfo(String user, String pass, String newpass, String email, String ip) ...{
try ...{
String data = "action=modifybio&username={0}&password={1}&Email={2}&NewPassword={3}&URL=http%3A%2F%2F{4}&dirtype=no&Submit=%C8%B7%B6%A8%D0%DE%B8%C4";
data = MessageFormat.format(data, new String[]...{user, pass, email, newpass, ip});
URL url = new URL("http://mycool.net/cgi-bin/modi.cgi");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) ...{
}
wr.close();
rd.close();
System.out.println("Update domain to :" + ip);
} catch (Exception e) ...{
e.printStackTrace();
}
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.MessageFormat;
public final class Main ...{
private static String oldIP = "";
public static void main(String[] args) ...{
while(true) ...{
String ip = getWanIP();
if (!oldIP.equals(ip)) ...{
updateDomainInfo("yourname", "oldpass", "newpass", "yourmail.domain.com", ip);
oldIP = ip;
}
try ...{
Thread.sleep(1000*60);
} catch (InterruptedException e) ...{
e.printStackTrace();
}
}
}
private static String getWanIP() ...{
BufferedReader in = null;
try ...{
URL url = new URL("http://vip.cn99.com/ret.php");
in = new BufferedReader(new InputStreamReader(url.openStream()));
String str = in.readLine();
return str;
} catch (MalformedURLException e) ...{
} catch (IOException e) ...{
} finally ...{
if (in != null)
try ...{
in.close();
}catch(IOException e) ...{}
}
return null;
}
private static void updateDomainInfo(String user, String pass, String newpass, String email, String ip) ...{
try ...{
String data = "action=modifybio&username={0}&password={1}&Email={2}&NewPassword={3}&URL=http%3A%2F%2F{4}&dirtype=no&Submit=%C8%B7%B6%A8%D0%DE%B8%C4";
data = MessageFormat.format(data, new String[]...{user, pass, email, newpass, ip});
URL url = new URL("http://mycool.net/cgi-bin/modi.cgi");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) ...{
}
wr.close();
rd.close();
System.out.println("Update domain to :" + ip);
} catch (Exception e) ...{
e.printStackTrace();
}
}
}
- ADSL搭建免费域名网站
- 个人网站搭建---godaddy域名+freewebhostingarea免费空间
- 免费打造个人网站,免费域名,免费空间,ftp使用,数据库等,免费就能搭建个人网站
- 免费域名和空间搭建个人网站——域名篇
- Windows Azure免费空间如何搭建PHP网站/数据库、域名绑定
- 免费域名和空间搭建个人网站——服务器篇
- 花生壳使用,网站域名搭建
- 网站搭建【1】-域名注册
- ideveloper-免费空间域名,简易免费安装百科网站教程!!!
- 新手免费搭建个人网站
- tk域名ml域名ga域名cf域名免费顶级域名获取及域名解析绑定IP发布网站
- [网站搭建] 阿里云搭建个人网站及域名绑定
- 网站搭建从零开始(一)域名
- 在某域名下搭建网站
- 注册域名,搭建自己的网站
- 用nat123免费域名建立自己的webgis网站
- 利用免费顶级域名,免费nat123域名解析服务,搭建免费企业邮箱
- 免费搭建独立博客,WordPress+独立域名+独立空间
- 关于PERL的一个小程序
- 神墓最新章节
- iis集成php出错查找实录
- 在线电影免费收看 免费的在线看电影 免费毛电影在线观看 免费新电影在线观看
- 我见过最牛X的程序员应聘者!
- ADSL搭建免费域名网站
- DOM2中的高级事件处理(Advanced Event Handling with DOM Level 2)
- 那小子真帅最新章节
- css中的 margin | padding | border 属性图释
- 3分钟内找出答案的人具有编程的潜力
- 125年来二十个无法回答的科学问题(转)
- 历届奥运会中国金牌榜 !
- 美国科学研究显示脑力锻炼可以延缓记忆力衰退
- 全球公认的最佳健康食品排行榜