diff --git a/aayushman_t/.vscode/settings.json b/aayushman_t/.vscode/settings.json new file mode 100644 index 0000000..311e001 --- /dev/null +++ b/aayushman_t/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.associations": { + "iostream": "cpp", + "fstream": "cpp", + "ostream": "cpp", + "limits": "cpp" + } +} \ No newline at end of file diff --git a/aayushman_t/.vscode/tasks.json b/aayushman_t/.vscode/tasks.json new file mode 100644 index 0000000..a5ee821 --- /dev/null +++ b/aayushman_t/.vscode/tasks.json @@ -0,0 +1,39 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build C++", + "type": "shell", + "command": "g++", + "args": [ + "src/*.cpp", + "-o", + "netflix_cli" + ], + "group": "build" + }, + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ] +} \ No newline at end of file diff --git a/aayushman_t/Dockerfile b/aayushman_t/Dockerfile new file mode 100644 index 0000000..6d96bb1 --- /dev/null +++ b/aayushman_t/Dockerfile @@ -0,0 +1,40 @@ +# Use Ubuntu 22.04 as the base image for building (it includes g++ and supports C++17) +FROM ubuntu:22.04 AS builder + +# Install g++ and other build essentials +RUN apt-get update && apt-get install -y \ + g++ \ + && rm -rf /var/lib/apt/lists/* + +# Set the working directory inside the container +WORKDIR /app + +# Copy all source files and the data directory into the container +COPY main.cpp movies.cpp tvShows.cpp ./ +COPY data/ ./data/ + +# Compile the C++ program with C++17 standard +RUN g++ -std=c++17 main.cpp -o netflix_clone + +# Use a smaller runtime image for the final stage +FROM ubuntu:22.04 + +# Install runtime dependencies (minimal) +RUN apt-get update && apt-get install -y \ + && rm -rf /var/lib/apt/lists/* + +# Set the working directory +WORKDIR /app + +# Copy the compiled binary and data directory from the builder stage +COPY --from=builder /app/netflix_clone . +COPY --from=builder /app/data ./data/ + +# Ensure the data directory is writable +RUN chmod -R 777 /app/data + +# Define a volume for the data directory to persist data +VOLUME /app/data + +# Set the entrypoint to run the application +CMD ["./netflix_clone"] \ No newline at end of file diff --git a/aayushman_t/a.out b/aayushman_t/a.out new file mode 100755 index 0000000..a68dded Binary files /dev/null and b/aayushman_t/a.out differ diff --git a/aayushman_t/data/Tvshows.txt b/aayushman_t/data/Tvshows.txt new file mode 100644 index 0000000..dabf386 --- /dev/null +++ b/aayushman_t/data/Tvshows.txt @@ -0,0 +1,50 @@ +Starbound Chronicles|Sci-Fi|8.4|5|10|3.99|14.99|0|0 +City of Shadows|Thriller|7.8|3|12|4.49|12.99|0|0 +Laughing Lofts|Comedy|7.5|6|20|3.49|11.99|0|0 +Hearts of Valor|Drama|8.2|4|15|4.29|13.99|0|0 +Mystic Realms|Fantasy|8.0|2|8|4.99|15.99|0|0 +Urban Legends|Crime|7.6|5|13|4.19|13.49|0|0 +Ghostly Tales|Horror|6.8|3|10|3.29|10.99|0|0 +Family Ties|Comedy|7.9|7|22|3.79|12.49|0|0 +Galactic Pioneers|Sci-Fi|8.7|4|12|4.79|16.99|0|0 +Dark Horizons|Thriller|7.4|2|14|4.39|12.99|0|0 +Echoes of Fate|Drama|8.5|6|16|4.59|14.49|0|0 +Loves Journey|Romance|7.7|3|18|3.89|13.29|0|0 +Hidden Kingdoms|Fantasy|8.1|5|10|4.69|15.49|0|0 +Street Justice|Crime|7.3|4|15|4.29|13.79|0|0 +Cursed Shadows|Horror|6.9|2|8|3.39|11.49|0|0 +Chuckle Haven|Comedy|7.6|8|24|3.69|12.29|0|0 +Nebula Quest|Sci-Fi|8.3|3|11|4.89|16.49|0|0 +Night Watch|Thriller|7.5|4|13|4.49|13.99|0|0 +Tides of Time|Drama|8.0|5|14|4.09|14.19|0|0 +Forever Bound|Romance|7.8|2|16|3.99|12.99|0|0 +Secret Plans|Crime|7.2|3|12|4.19|13.19|0|0 +Wild Frontiers|Adventure|7.9|4|10|4.99|15.79|0|0 +Haunted Echoes|Horror|6.7|2|9|3.49|11.29|0|0 +Giggle Street|Comedy|7.4|6|20|3.79|12.59|0|0 +Cosmic Travelers|Sci-Fi|8.6|5|12|4.99|17.99|0|0 +Silent Betrayal|Thriller|7.7|3|15|4.39|13.49|0|0 +Broken Bonds|Drama|8.1|4|17|4.29|14.29|0|0 +Starlit Hearts|Romance|7.6|2|14|3.89|12.79|0|0 +Dragons Legacy|Fantasy|8.3|6|10|4.79|16.29|0|0 +True Detectives|Crime|7.5|5|13|4.49|13.99|0|0 +Grim Whispers|Horror|6.6|3|8|3.29|11.19|0|0 +Laugh Lounge|Comedy|7.3|7|22|3.69|12.39|0|0 +Orbit Breakers|Sci-Fi|8.2|4|11|4.89|16.79|0|0 +Veiled Secrets|Thriller|7.9|2|12|4.59|13.79|0|0 +Fading Lights|Drama|8.4|5|16|4.19|14.59|0|0 +Moonlit Vows|Romance|7.5|3|18|3.99|13.49|0|0 +Shadow Hunters|Fantasy|8.0|4|9|4.69|15.29|0|0 +City Beat|Crime|7.4|6|14|4.29|13.69|0|0 +Dark Omens|Horror|6.5|2|10|3.39|11.39|0|0 +Joke Junction|Comedy|7.7|5|20|3.79|12.49|0|0 +Intergalactic|Sci-Fi|8.5|3|10|4.99|17.49|0|0 +Last Confession|Thriller|7.6|4|13|4.49|13.29|0|0 +Shades of Truth|Drama|8.3|5|15|4.39|14.39|0|0 +Hearts Aflame|Romance|7.4|2|16|3.89|12.69|0|0 +Enchanted Woods|Fantasy|8.2|3|8|4.79|15.99|0|0 +Night Patrol|Crime|7.8|4|12|4.29|13.89|0|0 +Eerie Nights|Horror|6.7|2|9|3.49|11.59|0|0 +Funny Folks|Comedy|7.5|6|22|3.69|12.69|0|0 +Stellar Voyage|Sci-Fi|8.4|5|11|4.89|16.99|0|0 +Twisted Paths|Thriller|7.7|3|14|4.59|13.99|0|0 diff --git a/aayushman_t/data/movies.txt b/aayushman_t/data/movies.txt new file mode 100644 index 0000000..a352267 --- /dev/null +++ b/aayushman_t/data/movies.txt @@ -0,0 +1,51 @@ +The Starfarer|Sci-Fi|8.2|2.15|3.99|14.99|0|0 +Midnight Run|Action|7.8|1.95|4.49|12.99|0|0 +Whispers in the Dark|Thriller|6.9|1.75|3.49|11.99|0|0 +Summer Dreams|Romance|8|2|3.99|13.99|0|0 +The Last Frontier|Adventure|7.5|2.25|4.99|15.99|0|0 +Echoes of Time|Drama|8.5|2.3|4.29|14.49|0|0 +Haunted Shadows|Horror|6.5|1.6|3.29|10.99|0|0 +City of Sparks|Comedy|7.2|1.85|3.79|12.49|0|0 +Quantum Leap|Sci-Fi|8.7|2.45|4.79|16.99|0|0 +The Iron Oath|Action|7.9|2.1|4.59|13.99|0|0 +Silent Waves|Drama|8.3|2.05|4.19|14.29|0|0 +Moonlit Secrets|Romance|7.7|1.9|3.89|12.99|0|0 +Crimson Tide|Thriller|7.4|2|4.39|13.49|0|0 +Jungle Quest|Adventure|7.1|2.2|4.69|15.49|0|0 +Ghostly Whispers|Horror|6.8|1.55|3.39|11.49|0|0 +Laugh Factory|Comedy|7.6|1.7|3.69|12.29|0|0 +Nebula Rising|Sci-Fi|8.4|2.35|4.89|16.49|0|0 +Bullet Storm|Action|7.3|1.8|4.29|13.29|0|0 +Tears of Tomorrow|Drama|8.1|2.25|4.09|14.19|0|0 +Love in Bloom|Romance|7.9|1.95|3.99|13.79|0|0 +Dark Alley|Thriller|6.7|1.65|3.59|11.99|0|0 +Skyward Bound|Adventure|7.8|2.3|4.99|15.79|0|0 +Phantom Manor|Horror|6.6|1.5|3.49|11.29|0|0 +Giggle Fest|Comedy|7.4|1.75|3.79|12.59|0|0 +Starlight Chronicles|Sci-Fi|8.6|2.5|4.99|17.99|0|0 +Rogue Agent|Action|7.7|2|4.49|13.99|0|0 +Fading Echoes|Drama|8.2|2.15|4.19|14.39|0|0 +Hearts Entwined|Romance|7.8|1.85|3.89|13.49|0|0 +Shadow Conspiracy|Thriller|7|1.9|4.29|12.99|0|0 +Wild Expedition|Adventure|7.6|2.25|4.79|15.29|0|0 +Grave Encounters|Horror|6.4|1.45|3.29|10.99|0|0 +Chuckle Town|Comedy|7.5|1.8|3.69|12.39|0|0 +Galactic Odyssey|Sci-Fi|8.3|2.4|4.89|16.79|0|0 +Thunder Strike|Action|7.9|1.95|4.59|13.79|0|0 +Broken Promises|Drama|8|2.2|4.09|14.09|0|0 +Starry Nights|Romance|7.7|1.9|3.99|13.29|0|0 +Hidden Truths|Thriller|6.9|1.7|3.59|11.79|0|0 +Mountain Quest|Adventure|7.4|2.3|4.69|15.19|0|0 +Cursed Woods|Horror|6.7|1.6|3.39|11.39|0|0 +Laugh Riot|Comedy|7.3|1.75|3.79|12.49|0|0 +Cosmic Voyage|Sci-Fi|8.5|2.45|4.99|17.49|0|0 +Blaze of Glory|Action|7.8|2|4.49|13.69|0|0 +Silent Tears|Drama|8.1|2.1|4.19|14.29|0|0 +Forever Yours|Romance|7.6|1.85|3.89|13.19|0|0 +Night Stalker|Thriller|7.1|1.8|4.29|12.89|0|0 +Desert Trek|Adventure|7.5|2.25|4.79|15.39|0|0 +Haunted Legacy|Horror|6.5|1.5|3.29|11.19|0|0 +Funny Bones|Comedy|7.4|1.7|3.69|12.29|0|0 +Interstellar Dreams|Sci-Fi|8.4|2.5|4.99|17.29|0|0 +Final Stand|Action|7.7|1.95|4.49|13.59|0|0 +dummy|dummy|0|0|0|0|0|0 diff --git a/aayushman_t/data/users.txt b/aayushman_t/data/users.txt new file mode 100644 index 0000000..8c48b1a --- /dev/null +++ b/aayushman_t/data/users.txt @@ -0,0 +1,3 @@ +aayushman:querty +aayush:rty:admin +test:pass:admin diff --git a/aayushman_t/main.cpp b/aayushman_t/main.cpp new file mode 100644 index 0000000..0fb77d4 --- /dev/null +++ b/aayushman_t/main.cpp @@ -0,0 +1,434 @@ + +#include +#include +#include +#include +#include +#include +#include "tvShows.cpp" +#include "movies.cpp" +using namespace std; +const string USER_DATA_FILE = "data/users.txt"; +struct User{ + string username; + string password; + bool isAdmin; +}; +class UserManager { + string currentUsername; + bool isAdmin; + + public: + void signUp() { + vector users = loadusers(); + cout << "Choose a username: "; + string username; + cin >> username; + + if (usernameExists(users, username)) { + cout << "Username already exists. Try logging in.\n"; + return; + } + cout<<"Enter a password: "; + string pass; + cin>>pass; + char AdminChoice; + + cout<<"Is this an Admin Account? (y/n):"<>AdminChoice; + bool newAdmin = false; + + if(AdminChoice=='y'){ + newAdmin = true; + } + else{ + newAdmin =false; + } + ofstream file(USER_DATA_FILE, ios::app); + if (file.is_open()) { + file << username << ":"< users = loadusers(); + cout << "Enter username: "; + string username; + string password; + cin >> username; + cout<<"Enter Password: "; + cin>>password; + for (const auto& user : users) { + if (user.username == username && user.password == password) { + currentUsername = username; + isAdmin = user.isAdmin; + cout << "Login successful. Welcome, " << username << "!" + << (isAdmin ? " (Admin)" : "") << "\n"; + + return true; + } + } + + + cout << "Login failed. Username not found.\n"; + return false; + } + string getCurrentUsername(){ + return currentUsername; + } + bool isCurrentUserAdmin() { + return isAdmin; + } + void viewAllContent(MoviesManager & moviemanager,TVShowManager & tvshowmanager ){ + cout << "\n=========== All Available Movies ===========\n"; + moviemanager.browse(); + cout << "\n=========== All Available Tv Shows ===========\n"; + tvshowmanager.browse(); + + } + + private: + vector loadusers() { + vector users; + ifstream file(USER_DATA_FILE); + string line; + while (getline(file, line)) { + size_t pos1 = line.find(":"); + if(pos1 == string::npos)continue; + size_t pos2 = line.find(":", pos1+1); + string username = line.substr(0, pos1); + string password; + bool isAdmin =false; + if(pos2 != string::npos){ + password = line.substr(pos1 +1 , pos2-pos1-1); + isAdmin = (line.substr(pos2) == ":admin"); + + }else{ + password = line.substr(pos1+1); + + } + users.push_back({username, password,isAdmin}); + + } + file.close(); + return users; + + } + + bool usernameExists(const vector& users, const string& username) { + for (const auto& user: users) { + if (user.username== username) + return true; + } + return false; + } + + + }; + + +int main() { + TVShowManager tvshowmanager; + MoviesManager moviemanager; + UserManager manager; + bool isloggedin =false; + while(!isloggedin){ + int choice; + cout << "1. Login\n2. Sign-Up\nEnter choice: "; + cin >> choice; + cin.ignore(numeric_limits::max(), '\n'); + switch (choice) { + case 1: + isloggedin= manager.login(); + break; + case 2: + manager.signUp(); + break; + default: + cout << "Invalid choice.\n"; + }} + if(isloggedin == true && (!manager.isCurrentUserAdmin() )){ + while(true){ + int action; + cout<<"1. Browse Movies\n2. Browse Tv Shows\n3. Search Content by title or genre"<>action; + cin.ignore(numeric_limits::max(), '\n'); + string purchaseFile = "data/purchased_" + manager.getCurrentUsername() + ".txt"; + string rentalFile = "data/rented_" + manager.getCurrentUsername() + ".txt"; + if(action ==2 ){ + cout<<"The format is: TITLE|GENRE|RATING|SEASONS|EPISODES PER SEASON|RENT COST|PURCHASE COST| AVAILABLE OR NOT"<>pur_ren_choice_tv; + cin.ignore(numeric_limits::max(), '\n'); + if(pur_ren_choice_tv == 1){ + string show_to_be_rented; + cout << "Enter show to rent: "; + getline(cin, show_to_be_rented); + + tvshowmanager.rentShow(show_to_be_rented); + ofstream out(rentalFile, ios::app); + if (out.is_open()) { + out << show_to_be_rented << endl; + out.close(); + cout << "Successfully rented: " << show_to_be_rented << endl; + } else { + cout << "Failed to save rental info.\n"; + } + } + else if(pur_ren_choice_tv == 2){ + string show_to_be_pur; + cout << "Enter the name of the show to purchase: "; + getline(cin, show_to_be_pur); + tvshowmanager.purchaseShow(show_to_be_pur); + ofstream out(purchaseFile, ios::app); + if (out.is_open()) { + out << show_to_be_pur << endl; + out.close(); + cout << "Successfully rented: " << show_to_be_pur << endl; + } else { + cout << "Failed to save rental info.\n"; + } + } + else if(pur_ren_choice_tv == 3){ + string Show_to_be_returned; + cout<<"Enter the Show to be returned: "<>Show_to_be_returned; + tvshowmanager.returnShow(Show_to_be_returned, manager.getCurrentUsername()); + } + else if(pur_ren_choice_tv == 4){ + string rentalfile = "data/rented_"+manager.getCurrentUsername()+".txt"; + string line; + ifstream in(rentalfile); + cout << "\n=========== Your Rented Shows ===========\n"; + bool found= false; + while(getline(in,line)){ + + for(auto&show:tvshowmanager.getShows()){ + if(show.title == line & show.isrented){ + show.display(); + found =true; + break; + } + } + } + if(!found){ + cout<<"No rented movie available"<>pur_ren_choice_mv; + cin.ignore(numeric_limits::max(), '\n'); + if(pur_ren_choice_mv == 1){ + string movie_to_be_rented; + cout << "Enter the name of the movie to rent: "; + getline(cin, movie_to_be_rented); + moviemanager.rentmovie(movie_to_be_rented); + ofstream out(rentalFile, ios::app); + if (out.is_open()) { + out << movie_to_be_rented << endl; + out.close(); + cout << "Successfully rented: " << movie_to_be_rented << endl; + } else { + cout << "Failed to save rental info.\n"; + } + } + else if(pur_ren_choice_mv == 2){ + string movie_to_be_pur; + cout << "Enter the name of the movie to purchase: "; + getline(cin, movie_to_be_pur); + moviemanager.purchasemovie(movie_to_be_pur); + ofstream out(purchaseFile, ios::app); + if (out.is_open()) { + out << movie_to_be_pur << endl; + out.close(); + cout << "Successfully rented: " << movie_to_be_pur << endl; + + } else { + cout << "Failed to save rental info.\n"; + } + } + else if(pur_ren_choice_mv ==3){ + string movie_to_return; + cout << "Enter the name of the movie to return: "; + getline(cin, movie_to_return); + moviemanager.returnMovie(movie_to_return,manager.getCurrentUsername()); + } + else if (pur_ren_choice_mv == 4){ + string rentalfile = "data/rented_"+manager.getCurrentUsername()+".txt"; + string line; + ifstream in(rentalfile); + cout << "\n=========== Your Rented Movies ===========\n"; + bool found= false; + while(getline(in,line)){ + + for(auto&movie:moviemanager.getMovies()){ + if(movie.title == line & movie.isrented){ + movie.display(); + found =true; + break; + } + } + } + if(!found){ + cout<<"No rented movie available"<> type; + cin.ignore(); + + cout << "Enter search keyword (title or genre): "; + string keyword; + getline(cin, keyword); + + if (type == 1) + moviemanager.searchMovie(keyword); + else if (type == 2) + tvshowmanager.searchShow(keyword); + else + cout << "Invalid search type.\n"; + } + + else{ + cout<<"Invalid Choice"; + } + }} + else if(isloggedin && manager.isCurrentUserAdmin()){ + while(true){ + int adminChoice; + cout<<"1. Movies \n2. TvShows"<>adminChoice; + cin.ignore(numeric_limits::max(), '\n'); + if(adminChoice ==1){ + int rem_add_mv; + cout<<"1. Add Movies \n2. Remove Movies\n3. List all Movies and Tv shows"<>rem_add_mv; + cin.ignore(numeric_limits::max(), '\n'); + if(rem_add_mv ==1){ + string title, genre; + float rating, rentCost, purchaseCost, duration; + char ch = 'y'; + + while(ch =='y'){ + cout << "Enter movie title: "; + getline(cin, title); + cout << "Enter genre: "; + getline(cin, genre); + cout << "Enter rating (0-10): "; + cin >> rating; + cout<<"Enter Duration "; + cin>> duration; + cout << "Enter rent cost: "; + cin >> rentCost; + cout << "Enter purchase cost: "; + cin >> purchaseCost; + + moviemanager.addMovie(title, genre, rating, duration, rentCost, purchaseCost); + cout<<"Want to enter more:(y/n) "; + cin>>ch; + cin.ignore(numeric_limits::max(), '\n'); + + } + + } + else if (rem_add_mv == 2) { + string title; + cout << "Enter movie title to remove: "; + getline(cin, title); + moviemanager.removeMovie(title); + } + else if(rem_add_mv ==3){ + manager.viewAllContent(moviemanager, tvshowmanager); + } + else { + cout << "Invalid admin choice.\n"; + } + } + else if(adminChoice == 2){ + int rem_add_sh; + cout<<"1. Add TvShows \n2. Remove TvShows\n3. List all Tv Shows and movies"<>rem_add_sh; + cin.ignore(numeric_limits::max(), '\n'); + if(rem_add_sh ==1){ + string title, genre; + float rating, rentCost, purchaseCost, season , ep_s; + char ch ='y'; + + + while(ch =='y'){ + cout << "Enter show title: "; + getline(cin, title); + cout << "Enter genre: "; + getline(cin, genre); + cout << "Enter rating (0-10): "; + cin >> rating; + cout << "Enter number of Seasons: "; + cin >> season; + cout << "Enter episode per season "; + cin >> ep_s; + cout << "Enter rent cost: "; + cin >> rentCost; + cout << "Enter purchase cost: "; + cin >> purchaseCost; + + + tvshowmanager.addshow(title, genre, rating,season,ep_s, rentCost, purchaseCost); + cout<<"Want to enter more:(y/n) "; + cin>>ch; + cin.ignore(numeric_limits::max(), '\n'); + + + } + + } + else if (rem_add_sh == 2) { + string title; + cout << "Enter movie title to remove: "; + getline(cin, title); + tvshowmanager.removeShow(title); + } + else if(rem_add_sh ==3){ + manager.viewAllContent(moviemanager, tvshowmanager); + } + else { + cout << "Invalid admin choice.\n"; + } + } + else{ + cout<<"Invalid Choice"< +#include +#include + +using namespace std; + +class Movies { +public: + string title; + string genre; + float rating; + float duration; + + float rentCost; + float purchaseCost; + bool isrented; + bool ispurchased; + + Movies(string t, string g, float r, float d, float rent, float buy) + { + title =t; + genre =g; + rating =r; + duration =d ; + rentCost =rent; + purchaseCost =buy; + isrented =false; + ispurchased =false; + } + + void display(){ + + cout< Moviess; + const string movieFile = "data/movies.txt"; + void loadFromFile() { + Moviess.clear(); + ifstream in(movieFile); + string line; + while (getline(in, line)) { + size_t pos = 0; + string token; + vector tokens; + while ((pos = line.find('|')) != string::npos) { + token = line.substr(0, pos); + tokens.push_back(token); + line.erase(0, pos + 1); + } + tokens.push_back(line); + + string title = tokens[0]; + string genre = tokens[1]; + float rating = stof(tokens[2]); + float duration = stof(tokens[3]); + float rent = stof(tokens[4]); + float buy = stof(tokens[5]); + bool isRented = stoi(tokens[6]); + bool isPurchased = stoi(tokens[7]); + Movies m(title, genre, rating, duration, rent , buy ); + m.isrented = isRented; + m.ispurchased = isPurchased; + Moviess.push_back(m); + } + in.close(); + } + + void saveToFile() { + ofstream out(movieFile); + for (const auto& m : Moviess) { + out << m.title << "|" << m.genre << "|" << m.rating << "|" + << m.duration << "|" << m.rentCost << "|" + << m.purchaseCost << "|" << m.isrented << "|"<< m.ispurchased<< "\n"; + } + out.close(); + } + public: + MoviesManager() { + loadFromFile(); + } + + void browse() { + cout << "\nAvailable Movies:\n"; + for (auto& show : Moviess) { + show.display(); + } + } + + void rentmovie(string title) { + for (auto& show : Moviess) { + if (show.title == title && !show.isrented && !show.ispurchased) { + show.isrented = true; + saveToFile(); + cout << title << " has been rented!"<title == title) { + Moviess.erase(i); + cout << "Movie '" << title << "' removed successfully!\n"; + return; + } + } + cout << "Movie not found.\n"; + } + void searchMovie(const string& query) { + bool found = false; + for (auto& movie : Moviess) { + if (movie.title.find(query) != string::npos || movie.genre.find(query) != string::npos) { + movie.display(); + found = true; + } + } + if (!found) { + cout << "No movie found matching: " << query << endl; + } + } + void returnMovie(const string& title, const string& username) { + string rentalFile = "data/rented_" + username + ".txt"; + + bool found = false; + for (auto& movie : Moviess) { + if (movie.title == title && movie.isrented) { + movie.isrented = false; + saveToFile(); + found = true; + cout << title << " has been returned successfully!\n"; + break; + } + } + if (!found) { + cout << "Movie not found or not rented.\n"; + return; + } + vector rentals; + ifstream in(rentalFile); + string line; + while (getline(in, line)) { + if (line != title) { + rentals.push_back(line); + } + } + in.close(); + ofstream out(rentalFile); + + for (const auto& rental : rentals) { + out << rental << "\n"; + } + out.close(); + + } + vector& getMovies() { + return Moviess; + } +}; diff --git a/aayushman_t/netflix b/aayushman_t/netflix new file mode 100755 index 0000000..de849d3 Binary files /dev/null and b/aayushman_t/netflix differ diff --git a/aayushman_t/netflix_cli b/aayushman_t/netflix_cli new file mode 100755 index 0000000..513ef0f Binary files /dev/null and b/aayushman_t/netflix_cli differ diff --git a/aayushman_t/tvShows.cpp b/aayushman_t/tvShows.cpp new file mode 100644 index 0000000..f4e55bd --- /dev/null +++ b/aayushman_t/tvShows.cpp @@ -0,0 +1,191 @@ +#include +#include +#include + +using namespace std; + +class TVShow { +public: + string title; + string genre; + float rating; + int seasons; + int episodesPerSeason; + float rentCost; + float purchaseCost; + bool isrented; + bool ispurchased; + + TVShow(string t, string g, float r, int s, int eps, float rent, float buy) + { + title =t; + genre =g; + rating =r; + seasons =s; + episodesPerSeason =eps; + rentCost =rent; + purchaseCost =buy; + isrented =false; + ispurchased = false; + } + + void display(){ + + cout< tvshows; + const string showFile = "data/Tvshows.txt"; + void loadFromFile() { + tvshows.clear(); + ifstream in(showFile); + string line; + while (getline(in, line)) { + size_t pos = 0; + string token; + vector tokens; + while ((pos = line.find('|')) != string::npos) { + token = line.substr(0, pos); + tokens.push_back(token); + line.erase(0, pos + 1); + } + tokens.push_back(line); + + string title = tokens[0]; + string genre = tokens[1]; + float rating = stof(tokens[2]); + float seasons = stof(tokens[3]); + float ep_s = stof(tokens[4]); + float rent = stof(tokens[5]); + float buy = stof(tokens[6]); + bool isRented = stoi(tokens[7]); + bool isPurchased = stoi(tokens[8]); + TVShow m(title, genre, rating, seasons,ep_s, rent , buy); + m.isrented = isRented; + m.ispurchased = isPurchased; + tvshows.push_back(m); + } + in.close(); + } + + void saveToFile() { + ofstream out(showFile); + for (const auto& m : tvshows) { + out << m.title << "|" << m.genre << "|" << m.rating << "|" + << m.seasons << "|" <title == title) { + tvshows.erase(i); + cout << "Show '" << title << "' removed successfully!\n"; + return; + } + } + cout << "Show not found.\n"; + } + void searchShow(const string& query) { + bool found = false; + for ( auto& show : tvshows) { + if (show.title.find(query) != string::npos || show.genre.find(query) != string::npos) { + show.display(); + found = true; + } + } + if (!found) { + cout << "No TV show found matching: " << query << endl; + } + } + void returnShow(const string& title, const string& username) { + string rentalFile = "data/rented_" + username + ".txt"; + + bool found = false; + for (auto show : tvshows) { + if (show.title == title && show.isrented) { + show.isrented = false; + saveToFile(); + found = true; + cout << title << " has been returned successfully!\n"; + break; + } + } + if (!found) { + cout << "Movie not found or not rented.\n"; + return; + } + vector rentals; + ifstream in(rentalFile); + string line; + while (getline(in, line)) { + if (line != title) { + rentals.push_back(line); + } + } + in.close(); + ofstream out(rentalFile); + + for (const auto& rental : rentals) { + out << rental << "\n"; + } + out.close(); + + + } + vector& getShows() { + return tvshows; + } + }; + + diff --git a/otw.md b/otw.md new file mode 100644 index 0000000..a1e8b89 --- /dev/null +++ b/otw.md @@ -0,0 +1,129 @@ +# level 0 +we need to connect to the host in this level. +we use ls to list the files +and then cat readme to read the file and see the password +ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If + +# level 1 + +cat ./- i the command we use in this level to read the file - in the home directory +263JGJPfgU6LtdEvgfWU1XP5yac29mFx + +# level 2 +cat "spaces in this file name" +MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx +# level 3 + +cd inhere/ +ls -al +cat .hidden +2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ +# level 4 +cd inhere/ +find . -type f | xargs file + and now read the file which has ASCII text type + 4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw +# level 5 +cd inhere/ +find . -type f -size 1033c ! -executable +will give the file location and the file which satisfy the parameter +HWasnPhtq9AVKe0dmk45nxy20cvUa6EG +# level 6 +find / -type f -user bandit7 -group bandit6 -size 33c + will get the file with the password +morbNTDkSW6jIlUc0ymOdMaLnOlFVAa + +# level 7 +as in this file there are quite a lot of strings so we will use the strings command to ease our task + +strings data.txt | grep "millionth" + +and you will get the passsword next to the word millionth +dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc +# level 8 + here will use the commands of uniq and sort to sort the content + + sort data.txt | uniq -c + + here -c tells us the count of a particular unique string and we will check the word woth only 1 occurunce that is the pass +FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey +# level 9 + + strings data.txt | grep "=" + +i t will give the password next to equals +FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey +# level 10 + cat data.txt + it will show a base64 encoded data to decrypt it + base64 -d data.txt + + will give the pass + dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr +# level 11 + we will use rot 13 method to decrypt it + data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m' + 7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4 + +# level 12 +cat data.txt + we will see that its a hex dump file + now we will try to reverse the hex dump file + +mkdir /temp/aayush +cp data.txt /tmp/aayush +cd /tmp/aayush +ls +xxd -r data.txt > data +ls + we will see that now we have created a file named data which is not a hex dump anymore lets see the file type of the file +file data +we will get a file with the extension of gzip so we move the data file with a new extension .gz +mv data file.gz +gzip -d file.gz +file file +mv file file.bz2 +bzip2 -d file.bz2 +file file +mv file file.gz +gzip -d file.gz +file file + now its a tar archive +mv file file.tar +tar xf file.tar +ls +file data7.bin +mv data7.bin data.tar +tar xf data.tar +ls +file data6.bin +mv data6.bin data.bz2 +bzip2 -d data.bz2 +ls +file data +mv data data.tar +tar xf data.tar +ls +file data8.bin +mv data8.bin data.gz +gzip2 -d data.gz +ls +file data +cat data + NOW this will give us the pass + FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn +#level 13 +ls + we will get the sshkey.private which is a private key +ssh -i sshkey.private bandit14@localhost -p 2220 + now we are in bandit 14 +cat etc/bandit_pass/bandit14 + and WE will get the pass +MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS +#level 14 +we will use the netap command +nc localhost 30000 # hit enter +MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS +and now entered the password for the previous level +and we will get the password for the next level +