2013年9月5日 星期四

NCCU宿網註冊圖解

各位同學們好,

因應FB不好做圖解,
所以在此做圖解說明宿網註冊程序

step 1. 下載程式並解壓縮  LINK

step 2. 點兩下執行,有些用Windows 8 的會被smartscreen擋下來,請參閱這裡來取消


step 3. 同意變更電腦 (只有Vista以上才會出現這個畫面)


step 4. 選擇語言



step 5. 選擇作業系統



step 6. 複製網卡卡號,如果你的電腦比較特殊它找不到的話那麼只好請你勞駕命令提示字元來找了



step 7. 接著會問你想不想開啟註冊宿網的網頁,請打入yes或no (這裡為了版面所以打no跳過網頁部份,想註冊IP的請打yes)



step 8. 輸入IP



step 9. 完成



到這裡就完成囉,如果有任何問題的話歡迎留言詢問喔:)

目前Windows 8可能執行上會有一些問題,若你無法執行成功,麻煩請依這裡的設定方法設定,並向我回報bug,謝謝

以下是這支的程式碼,如果你沒有興趣的話可以跳過沒關係
#include<fstream>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
fstream io;
int lang;
bool all_0( char *a )
{
    for( int i = 0; i <= 16; ++i )
        if( i % 3 != 2 && a[ i ] != '0' )
            return false;
    return true;
}

void get_addr()
{
    char word[ 1024 ] = { 0 };
    system( "ipconfig /all > addr.txt" );
    FILE *file = fopen( "addr.txt", "r" );
search:
    if( lang == 1 )
        while( fscanf( file, "%s", word ) != EOF && strcmp( word, "區域連線" ) && strcmp( word, "區域連線:" ) && strcmp( word, "乙太網路" ) && strcmp( word, "乙太網路:" ) );
    else
        while( fscanf( file, "%s", word ) != EOF && strcmp( word, "local" ) && strcmp( word, "local" ) && strcmp( word, "ethernet" ) && strcmp( word, "Ethernet" ) );
    while( fscanf( file, "%s", word ) != EOF && ( !( word[ 2 ] == '-' && word[ 5 ] == '-' && word[ 8 ] == '-' && word[ 11 ] == '-' && word[ 14 ] == '-' && strlen( word ) == 17 ) || all_0( word ) ) )
        if( !strcmp( word, "VPN" ) || !strcmp( word, "virtual" ) || !strcmp( word, "Virtual" ) || !strcmp( word, "Bluetooth" ) )
            goto search;
    word[ 2 ] = word[ 5 ] = word[ 8 ] = word[ 11 ] = word[ 14 ] = ':';
    if( word[ 2 ] == ':' && word[ 5 ] == ':' && word[ 8 ] == ':' && word[ 11 ] == ':' && strlen( word ) == 17 )
        io << endl << word << endl;
    else
        io << "Sorry, I couldn't find your MAC address.\nYou may use command prompt to get it.\n";
    io.close();
    fclose( file );
    system( "notepad mac.txt" );
    system( "del /F mac.txt addr.txt" );
}

void set8()
{
    int a, b;
    char cmd[ 1024 ];
    scanf( "%*d.%*d.%d.%d", &a, &b );
    if( lang == 1 )
        sprintf( cmd, "netsh interface ipv4 set address name=\"乙太網路\" source=static address=140.119.%d.%d mask=255.255.255.0 gateway=140.119.%d.254", a, b, a );
    else
        sprintf( cmd, "netsh interface ipv4 set address name=\"Ethernet\" source=static address=140.119.%d.%d mask=255.255.255.0 gateway=140.119.%d.254", a, b, a );
    system( cmd );
    if( lang == 1 )
        sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"乙太網路\" address=140.119.1.110 index=1" );
    else
        sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"Ethernet\" address=140.119.1.110 index=1" );
    system( cmd );
    if( lang == 1 )
        sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"乙太網路\" address=140.119.252.12 index=2" );
    else
        sprintf( cmd, "netsh interface ipv4 add dnsserver name=\"Ethernet\" address=140.119.252.12 index=2" );
    system( cmd );
}

void set()
{
    int a, b;
    char cmd[ 1024 ];
    scanf( "%*d.%*d.%d.%d", &a, &b );
    if( lang == 1 )
    sprintf( cmd, "netsh interface ipv4 set address \"區域連線\" static 140.119.%d.%d 255.255.255.0 140.119.%d.254\n", a, b, a );
    else
    sprintf( cmd, "netsh interface ipv4 set address \"local area connection\" static 140.119.%d.%d 255.255.255.0 140.119.%d.254\n", a, b, a );
    system( cmd );
    if( lang == 1 )
    sprintf( cmd, "netsh interface ipv4 set dnsservers name=\"區域連線\" static 140.119.1.110 primary" );
    else
    sprintf( cmd, "netsh interface ipv4 set dnsservers name=\"local area connection\" static 140.119.1.110 primary" );
    system( cmd );
    if( lang == 1 )
    sprintf( cmd, "netsh interface ipv4 add dnsservers name=\"區域連線\" 140.119.252.12 index=2" );
    else
    sprintf( cmd, "netsh interface ipv4 add dnsservers name=\"local area connection\" 140.119.252.12 index=2" );
    system( cmd );
}

void setxp()
{
    int a, b;
    char cmd[ 1024 ];
    scanf( "%*d.%*d.%d.%d", &a, &b );
    if( lang == 1 )
    sprintf( cmd, "netsh interface ip set address \"區域連線\" static 140.119.%d.%d 255.255.255.0 140.119.%d.254 1\n", a, b, a );
    else
    sprintf( cmd, "netsh interface ip set address \"local area connection\" static 140.119.%d.%d 255.255.255.0 140.119.%d.254 1\n", a, b, a );
    system( cmd );
    if( lang == 1 )
    sprintf( cmd, "netsh interface ip set dns \"區域連線\" static 140.119.1.110" );
    else
    sprintf( cmd, "netsh interface ip set dns \"local area connection\" static 140.119.1.110" );
    system( cmd );
    if( lang == 1 )
    sprintf( cmd, "netsh interface ip add dns \"區域連線\" 140.119.252.12" );
    else
    sprintf( cmd, "netsh interface ip add dns \"local area connection\" 140.119.252.12" );
    system( cmd );
}

int main()
{
    int os;
    string open;
    system( "@echo off" );
    io.open( "mac.txt", fstream::in | fstream::out | fstream::app );
    cout << "請選語言 Select language: \n1)中文 2)English\n";
    cin >> lang;
    if( lang == 1 )
        cout << "您的作業系統是? 1)XP 2)Vista 3)7 4)8\n";
    else
        cout << "What's your operating system? 1)XP 2)Vista 3)7 4)8\n";
    cin >> os;
    if( lang == 1 )
        io << "這是你的卡號,請直接複製此卡號\n關閉後將出現宿網註冊頁面\n";
    else
        io << "\nThe following is your MAC address. Please copy this to your clipboard.\nIP registration page will show up after this file is closed.\n";
    get_addr();
again:
    if( lang == 1 )
        cout << "是否開啟註冊註冊頁面? (yes/no)" << endl;
    else
        cout << "Would you like to open ip registration page? (yes/no)" << endl;
    cin >> open;
    if( open == "yes" )
        system( "start http://flow2.nccu.edu.tw/Reg/stulogin.php" );
    else if( open != "no" )
    {
        cout << "Please enter yes or no\n";
        goto again;
    }
    if( lang == 1 )
        cout << "輸入您方才註冊好的宿網IP: ";
    else
        cout << "Enter the IP address you just got from NCCU: ";
    cout << "\nExample: 140.119.123.234\n";
    if( os == 2 || os == 3 )
        set();
    else if( os == 1 )
        setxp();
    else if( os == 4 )
        set8();
    if( lang == 1 )
        cout << "設定完成 :D\n";
    else
        cout << "Configuration successful! :D\n";
    system( "pause" );

    return 0;
}




沒有留言:

張貼留言