Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var senddata = {
- "Sender": "Grant",
- "To": "Node-Server",
- "Password": "NodeSender12",
- "data": []
- }
- $(".pass").attr({
- "type": "password"
- });
- $(".flexer").on("click", function() {
- $(".images").css({
- "filter": "blur(8px)"
- });
- })
- $(".images").on("click", function() {
- $(".images").css({
- "filter": "blur(0px)"
- });
- $(".user").attr({
- "placeholder": "Please Enter Username"
- });
- $(".pass").attr({
- "placeholder": "Please Enter Password"
- });
- })
- $("form").on("submit", onchanges)
- function onchanges() {
- // data for the events and dates
- var tArray =[$(".user").val(),$(".pass").val()]
- console.log(tArray)
- for (var i = 0; i <= 1; i++) {
- var hashes = md5(tArray[i]);
- senddata.data.push(hashes)
- // "2063c1608d6e0baf80249c42e2be5804"
- console.log(hashes + senddata.data[i])
- }
- return false;
- grabAndPut()
- }
- var x = 0;
- function grabAndPut() {
- var ps= JSON.stringify(senddata)
- console.log(ps)
- $.ajax({
- method: 'POST',
- url: '/people',
- data: senddata,
- success: function() {
- console.log("has sent the data to localhost:8080/serverBox" + datajson)
- },
- contentType: 'application/x-www-form-urlencoded'
- })
- }grabAndPut()
- var http = require("http"),
- fs = require("fs"),
- express = require("express"),
- mysql = require("mysql"),
- morgan = require('morgan'),
- bp = require("body-parser"),
- cookieParser = require("cookie-parser"),
- connect = require("connect"),
- bcrypt = require("bcrypt"),
- md5 = require('md5')
- // console.log(md5('message'));
- // sql connection
- // md5 checker
- // require the username and password
- /*
- function hash(){
- const saltRounds = 12;
- password = "APPLES"
- username = "grant3939"
- bcrypt.genSalt(saltRounds,function (err,salt){
- bcrypt.hash(password, salt, function(err, hash) {
- console.log(hash)
- // Store hash in your password DB.
- });
- })
- }hash()
- */
- var username="nothing"
- var password="random"
- var sqldata = `INSERT INTO Passwords (Password, Username) VALUES (${password},${username})`
- var sqlq = mysql.createConnection({
- host: "NOT TO DIS",
- user: "jack",
- password: "Popcorn!1",
- database: "shit"
- })
- sqlq.connect(function(err) {
- console.log("Connected!");
- sqlq.query(sqldata,[password,username], function (err, result) {
- console.log("Results" + result);
- //console.log(result.affectedRows)
- });
- });
- // express
- // app useability
- //EX:
- //morgan('tiny')
- //morgan(':method :url :status :res[content-length] :response-time ms')
- var app = express();
- var uep = bp.urlencoded({
- extended: false
- })
- var jsonParser = bp.json()
- app.use(express.static("static"))
- // end of requires
- //start of static files excluding server.js
- app.get("/", function(req, res) {
- res.sendFile(__dirname + "/static/index.html")
- });
- app.post("/people", uep, function(req, res) {
- if (!req.body) return res.sendStatus(400)
- var body = JSON.parse(req.body)
- res.send(req.body)
- })
- var senddataEvents = {
- "Sender": "Grant",
- "To": "Node-Server",
- "Password": "NodeSender12",
- "data": []
- }
- app.get("/people", function(req, res) {
- res.writeHead(200, {
- 'Content-Type': 'text/html'
- })
- res.write("<b>some data</b>" + req.body + "<script>console.log('hello')</script>")
- res.end()
- })
- // listener
- /*
- var sqlpostData = [];
- function data(){
- for (let i =0; i <=8; i++)
- var login = jsonDataLogin.data[i]
- sqlpostData.append(login)
- }
- */
- // end
- //end
- // end
- app.listen(3000, function() {
- console.log("server started on 3000 server static files from node, connection waiting......")
- })
Add Comment
Please, Sign In to add comment