Notes
![]() ![]() Notes - notes.io |
const app = express();
const port = 1233;
const url = require('url');
var jwt = require('jsonwebtoken');
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '1598753d',
database: 'users'
});
var users_id_array = [];
app.get('/signin/:app_id/:secret_id/',(req,res)=>{
var {app_id,secret_id} = req.params;
var query = url.parse(req.url,true);
if (app_id == "c4ca4238a0b923820dcc509a6f75849b") {
if (secret_id == "ec308451c1d095c528cfa3c009ea7235") {
if(query.query.username!=undefined && query.query.password!=undefined){
connection.connect(()=>{
connection.query('SELECT id FROM users WHERE username="' + query.query.username + '" and password="' + query.query.password + '"', function (error, results, fields) {
if (error) throw error;
if(results.length==0){
res.json({error:"Invalid username or password.Please try again."});
}else{
var token = jwt.sign({ app_id, secret_id }, 'supersecret', { expiresIn: 120 });
users_id_array.push({[token]:results[0]["id"]});
res.end(token);
setTimeout(function(){
const this_token = token;
for(var i = 0;i<users_id_array.length;i++){
if(users_id_array[i][this_token]){
users_id_array.splice(i,1);
}
}
},120000);
}
});
});
}else{
res.json({error:"Invalid paramaters."});
}
}else{
res.json({ error: "This secret key is not registered to the server" });
}
}else{
res.json({ error: "This app id is not registered to the server" });
}
});
app.get('/get/:app_id/:secret_id/:token/',(req,res)=>{
var {app_id,secret_id,token} = req.params;
if (app_id == "c4ca4238a0b923820dcc509a6f75849b") {
if (secret_id == "ec308451c1d095c528cfa3c009ea7235") {
jwt.verify(token, 'supersecret', function (err, decoded) {
if (!err) {
var id = 0;
for (var i = 0; i < users_id_array.length; i++) {
if(users_id_array[i][token]){
id = parseInt(users_id_array[i][token]);
}
}
if(id!=0){
connection.connect(()=>{
var query = url.parse(req.url,true);
var column_array = [];
var query_string = query.query.fields;
var query_column;
if(query_string!=undefined){
query_column = query.query.fields.split(",");
}
var auth = false;
if(query.query.fields!=undefined){
connection.query('SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "users"', function (error, results, fields) {
if (error) throw error;
for (var i = 0; i < results.length; i++) {
column_array.push(results[i]["COLUMN_NAME"]);
}
for (var i = 0; i < query_column.length; i++) {
if(!column_array.includes(query_column[i])){
auth = true;
}
}
if(!auth){
connection.query('SELECT '+query_string+' FROM users WHERE id=' + id + ' ', function (error, results, fields) {
if (error) throw error;
res.json(results);
});
}else{
res.json({error:"Invalid fields paramaters"});
}
});
}else{
connection.query('SELECT * FROM users WHERE id=' + id + ' ', function (error, results, fields) {
if (error) throw error;
res.json(results);
});
}
});
}else{
res.json({error:"Invalid id please try again later."});
}
}else{
res.json({error:"Invalid token"});
}
});
}else{
res.json({ error: "This secret key is not registered to the server" });
}
}else{
res.json({ error: "This app id is not registered to the server" });
}
});
app.listen(port, () => console.log(`${port} üzerinden dinleniyor.`));
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team