Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var main = require('./proccess.js')
- var error = main.err;
- var url = require('url');
- var prompt = require('prompt-sync')();
- var mysql = require('mysql');
- var http = require('http');
- var fs = require('fs');
- var connection = mysql.createConnection({
- host: 'localhost',
- user: 'root', //just using root for my personal testing.
- password: 'root',
- database: 'crypt',
- port: '8889'
- });
- connection.query('SELECT * FROM alldata',
- function(err, rows, fields) {
- if (err) throw err;
- var usr = (rows[0].Username);
- var password = (rows[0].Password);
- var searchterm = (rows[0].Name);
- var Address = (rows[0].Address);
- console.log("Welcome to Crytonite!")
- var usrin = prompt('Username: ');
- if (usrin === usr, usr+' '){
- var passin = prompt('Password: ')
- }
- else
- {
- var regq = prompt("Sorry,we could not find that username, would you like to register? Y/N ")
- if (regq === "Y")
- {
- var usrnew = prompt("Chose a username" + " ");
- if (usrnew = ''){
- console.log("You can't have a blank username... sorry.");
- var usrnew = prompt("Chose a username");}
- if (usrnew === usr){
- var usrnew = prompt("Sorry! that username is taken, please chose
- another");
- }
- else{
- var pswq = prompt("Chose a password ")
- if (pswq === ''){
- pswq = prompt("You will need a password you know...")
- }
- }
- }
- else
- {
- console.log("You can't use our services with out an account")
- }
- };
- if (passin === password){
- console.log("Hello!")
- var command = prompt("So, what can we do for " + "" +usr+ "?" + "
- add/search/remove ")
- }
- //var command = prompt("Any thing else we can do for you?")
- if (command === "search"){
- var search = prompt(" What are you after?? ")}
- else{
- if (command === "add"){
- var adname = prompt("File or program name: ");
- var addrs = prompt("Direct link to download your program or file: ");
- exports.name = adname;
- exports.address = addrs;
- var error = main.err;
- if (error) console.log('oops! err')
- if (adname === searchterm){
- console.log('Done')
- }
- }
- }
- //)
- if (search === searchterm){
- var match = prompt("Okay, we found. " + search + +" " + "Is this
- you're after?");
- if (match === 'Y', 'Yes', 'yes', 'y'){
- console.log("Okay, we will download to the default directory.")
- var file = fs.createWriteStream("file.jpg");
- var request = http.get(Address, function(response) {
- response.pipe(file);
- });
- }
- if (match = 'n', 'N', 'No'){
- var match = prompt("Would you like to search again?");
- }
- }
- }
- //Not sure why I need a ',' before process.on, Visual Studio Code said
- //I need to do so
- ,process.on( 'SIGINT', function() {
- console.log( "nGoodbye!" );
- process.exit();
- }))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement