/* QnDUB, version 0.2.2 This is Open Source Software. Anyone can use it. For free. Just give me some credit, mmkay? ;) Copyright Cat Chapman, 2006. */ // yusef:added program loop and Linux support // cat:0.2.2 - Removed Linux support. This is a Windows binary, it'd be easier just to make Linux a separate program. :P #include #include #include using namespace std; int main() { string blockme; char choice; char answer; do { system("cls"); cout << "Welcome to QnDUB, the Quick n Dirty URL Blocker for Windows.\n\n"; //Added "www." cout << "What URL would you like to block? Follow this format: www.website.com" << endl; cin >> blockme; while (blockme[1]!='w' && blockme[4]!='.') { cout<<"\nPlease add www. to your web address"; cout << "\nWhat URL would you like to block? Follow this format: www.website.com" << endl; cin >> blockme; } cout << "What OS are you running? \n\ta: Windows XP \n\tb: Windows 2000\n\tc: Windows 98/ME" << endl; cin >> choice; if( choice == 'a' ) { ofstream file("/Windows/System32/Drivers/etc/hosts", ios::app); if (! file) { cout << "Error opening output file" << endl; return -1; } file << "\n127.0.0.1 " << blockme << endl; file.close(); cout << "Success! " << blockme << " was successfully blocked!" << endl; } else if( choice == 'b' ) { ofstream file2("/Winnt/System32/Drivers/etc/hosts", ios::app); if (! file2) { cout << "Error opening output file" << endl; return -1; } file2 << "\n127.0.0.1 " << blockme << endl; file2.close(); cout << "Success! " << blockme << " was successfully blocked!" << endl; } else if(choice == 'c' ) { ofstream file3("/Windows/hosts", ios::app); if (! file3) { cout << "Error opening output file" << endl; return -1; } file3 << "\n127.0.0.1 " << blockme << endl; file3.close(); cout << "Success! " << blockme << " was successfully blocked!" << endl; } else cout << "Invalid choice. Please run this program again" << endl; cout<<"Do you want to run this program again? "; cin>>answer; } while (answer=='y' || answer=='Y'); return 0; }