Guest User

Untitled

a guest
Jul 23rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. var senddata = {
  2. "Sender": "Grant",
  3. "To": "Node-Server",
  4. "Password": "NodeSender12",
  5. "data": []
  6. }
  7.  
  8.  
  9.  
  10. $(".pass").attr({
  11. "type": "password"
  12. });
  13.  
  14. $(".flexer").on("click", function() {
  15. $(".images").css({
  16. "filter": "blur(8px)"
  17. });
  18. })
  19.  
  20. $(".images").on("click", function() {
  21. $(".images").css({
  22. "filter": "blur(0px)"
  23. });
  24. $(".user").attr({
  25. "placeholder": "Please Enter Username"
  26. });
  27. $(".pass").attr({
  28. "placeholder": "Please Enter Password"
  29. });
  30. })
  31.  
  32.  
  33. $("form").on("submit", onchanges)
  34.  
  35.  
  36.  
  37.  
  38. function onchanges() {
  39.  
  40. // data for the events and dates
  41. var tArray =[$(".user").val(),$(".pass").val()]
  42. console.log(tArray)
  43.  
  44. for (var i = 0; i <= 1; i++) {
  45. var hashes = md5(tArray[i]);
  46. senddata.data.push(hashes)
  47. // "2063c1608d6e0baf80249c42e2be5804"
  48. console.log(hashes + senddata.data[i])
  49. }
  50.  
  51. return false;
  52.  
  53. grabAndPut()
  54.  
  55. }
  56.  
  57.  
  58. var x = 0;
  59.  
  60. function grabAndPut() {
  61. var ps= JSON.stringify(senddata)
  62. console.log(ps)
  63. $.ajax({
  64. method: 'POST',
  65. url: '/people',
  66. data: senddata,
  67. success: function() {
  68. console.log("has sent the data to localhost:8080/serverBox" + datajson)
  69. },
  70. contentType: 'application/x-www-form-urlencoded'
  71. })
  72. }grabAndPut()
  73.  
  74. var http = require("http"),
  75. fs = require("fs"),
  76. express = require("express"),
  77. mysql = require("mysql"),
  78. morgan = require('morgan'),
  79. bp = require("body-parser"),
  80. cookieParser = require("cookie-parser"),
  81. connect = require("connect"),
  82. bcrypt = require("bcrypt"),
  83. md5 = require('md5')
  84.  
  85.  
  86.  
  87.  
  88. // console.log(md5('message'));
  89.  
  90. // sql connection
  91.  
  92. // md5 checker
  93.  
  94.  
  95.  
  96. // require the username and password
  97.  
  98. /*
  99. function hash(){
  100. const saltRounds = 12;
  101. password = "APPLES"
  102. username = "grant3939"
  103. bcrypt.genSalt(saltRounds,function (err,salt){
  104. bcrypt.hash(password, salt, function(err, hash) {
  105. console.log(hash)
  106. // Store hash in your password DB.
  107. });
  108. })
  109. }hash()
  110. */
  111.  
  112. var username="nothing"
  113. var password="random"
  114. var sqldata = `INSERT INTO Passwords (Password, Username) VALUES (${password},${username})`
  115.  
  116.  
  117. var sqlq = mysql.createConnection({
  118. host: "NOT TO DIS",
  119. user: "jack",
  120. password: "Popcorn!1",
  121. database: "shit"
  122. })
  123.  
  124. sqlq.connect(function(err) {
  125. console.log("Connected!");
  126. sqlq.query(sqldata,[password,username], function (err, result) {
  127. console.log("Results" + result);
  128. //console.log(result.affectedRows)
  129.  
  130. });
  131. });
  132.  
  133.  
  134. // express
  135.  
  136.  
  137. // app useability
  138.  
  139. //EX:
  140. //morgan('tiny')
  141. //morgan(':method :url :status :res[content-length] :response-time ms')
  142.  
  143.  
  144. var app = express();
  145.  
  146. var uep = bp.urlencoded({
  147. extended: false
  148. })
  149. var jsonParser = bp.json()
  150. app.use(express.static("static"))
  151. // end of requires
  152. //start of static files excluding server.js
  153. app.get("/", function(req, res) {
  154. res.sendFile(__dirname + "/static/index.html")
  155. });
  156.  
  157.  
  158. app.post("/people", uep, function(req, res) {
  159. if (!req.body) return res.sendStatus(400)
  160. var body = JSON.parse(req.body)
  161. res.send(req.body)
  162. })
  163.  
  164. var senddataEvents = {
  165. "Sender": "Grant",
  166. "To": "Node-Server",
  167. "Password": "NodeSender12",
  168. "data": []
  169. }
  170.  
  171.  
  172. app.get("/people", function(req, res) {
  173. res.writeHead(200, {
  174. 'Content-Type': 'text/html'
  175. })
  176. res.write("<b>some data</b>" + req.body + "<script>console.log('hello')</script>")
  177. res.end()
  178.  
  179. })
  180.  
  181.  
  182.  
  183.  
  184.  
  185. // listener
  186. /*
  187. var sqlpostData = [];
  188.  
  189. function data(){
  190. for (let i =0; i <=8; i++)
  191. var login = jsonDataLogin.data[i]
  192. sqlpostData.append(login)
  193. }
  194. */
  195. // end
  196. //end
  197. // end
  198.  
  199. app.listen(3000, function() {
  200. console.log("server started on 3000 server static files from node, connection waiting......")
  201. })
Add Comment
Please, Sign In to add comment