Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. var main = require('./proccess.js')
  2. var error = main.err;
  3. var url = require('url');
  4. var prompt = require('prompt-sync')();
  5. var mysql = require('mysql');
  6. var http = require('http');
  7. var fs = require('fs');
  8. var connection = mysql.createConnection({
  9. host: 'localhost',
  10. user: 'root', //just using root for my personal testing.
  11. password: 'root',
  12. database: 'crypt',
  13. port: '8889'
  14.  
  15. });
  16. connection.query('SELECT * FROM alldata',
  17. function(err, rows, fields) {
  18. if (err) throw err;
  19. var usr = (rows[0].Username);
  20. var password = (rows[0].Password);
  21. var searchterm = (rows[0].Name);
  22. var Address = (rows[0].Address);
  23.  
  24. console.log("Welcome to Crytonite!")
  25. var usrin = prompt('Username: ');
  26. if (usrin === usr, usr+' '){
  27. var passin = prompt('Password: ')
  28. }
  29. else
  30. {
  31. var regq = prompt("Sorry,we could not find that username, would you like to register? Y/N ")
  32. if (regq === "Y")
  33. {
  34. var usrnew = prompt("Chose a username" + " ");
  35. if (usrnew = ''){
  36. console.log("You can't have a blank username... sorry.");
  37. var usrnew = prompt("Chose a username");}
  38. if (usrnew === usr){
  39. var usrnew = prompt("Sorry! that username is taken, please chose
  40. another");
  41. }
  42. else{
  43. var pswq = prompt("Chose a password ")
  44. if (pswq === ''){
  45. pswq = prompt("You will need a password you know...")
  46. }
  47. }
  48.  
  49. }
  50. else
  51. {
  52. console.log("You can't use our services with out an account")
  53. }
  54. };
  55.  
  56. if (passin === password){
  57. console.log("Hello!")
  58. var command = prompt("So, what can we do for " + "" +usr+ "?" + "
  59. add/search/remove ")
  60. }
  61. //var command = prompt("Any thing else we can do for you?")
  62. if (command === "search"){
  63. var search = prompt(" What are you after?? ")}
  64. else{
  65. if (command === "add"){
  66. var adname = prompt("File or program name: ");
  67. var addrs = prompt("Direct link to download your program or file: ");
  68. exports.name = adname;
  69. exports.address = addrs;
  70. var error = main.err;
  71. if (error) console.log('oops! err')
  72. if (adname === searchterm){
  73. console.log('Done')
  74. }
  75. }
  76. }
  77. //)
  78. if (search === searchterm){
  79. var match = prompt("Okay, we found. " + search + +" " + "Is this
  80. you're after?");
  81. if (match === 'Y', 'Yes', 'yes', 'y'){
  82. console.log("Okay, we will download to the default directory.")
  83.  
  84.  
  85. var file = fs.createWriteStream("file.jpg");
  86. var request = http.get(Address, function(response) {
  87. response.pipe(file);
  88. });
  89.  
  90. }
  91. if (match = 'n', 'N', 'No'){
  92. var match = prompt("Would you like to search again?");
  93. }
  94. }
  95.  
  96. }
  97. //Not sure why I need a ',' before process.on, Visual Studio Code said
  98. //I need to do so
  99. ,process.on( 'SIGINT', function() {
  100. console.log( "nGoodbye!" );
  101.  
  102. process.exit();
  103. }))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement