funciones de archivos
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Generated
+29
@@ -82,6 +82,14 @@
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"busboy": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
|
||||
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
|
||||
"requires": {
|
||||
"dicer": "0.3.0"
|
||||
}
|
||||
},
|
||||
"bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
@@ -177,6 +185,14 @@
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
|
||||
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
|
||||
},
|
||||
"dicer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
|
||||
"integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
|
||||
"requires": {
|
||||
"streamsearch": "0.1.2"
|
||||
}
|
||||
},
|
||||
"ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
@@ -234,6 +250,14 @@
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"express-fileupload": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.1.6.tgz",
|
||||
"integrity": "sha512-w24zPWT8DkoIxSVkbxYPo9hkTiLpCQQzNsLRTCnecBhfbYv+IkIC5uLw2MIUAxBZ+7UMmXPjGxlhzUXo4RcbZw==",
|
||||
"requires": {
|
||||
"busboy": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"finalhandler": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
|
||||
@@ -753,6 +777,11 @@
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
||||
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
|
||||
},
|
||||
"streamsearch": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
|
||||
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
"dependencies": {
|
||||
"bcrypt": "^3.0.8",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1"
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
|
||||
|
||||
app.get('/descargar_cartel', (req, res) => {
|
||||
res.download(__dirname + `/../files/cartel-${req.query.id_persona}.docx`);
|
||||
})
|
||||
|
||||
module.exports = app;
|
||||
@@ -0,0 +1,10 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express')
|
||||
var app = express();
|
||||
|
||||
|
||||
app.get('/descargar_ponencia', (req, res) => {
|
||||
res.download(__dirname + `/../files/ponencia-${req.query.id_persona}.docx`);
|
||||
})
|
||||
|
||||
module.exports = app;
|
||||
@@ -7,5 +7,7 @@ app.use(require('./traer_pais'));
|
||||
app.use(require('./loggin_admin'));
|
||||
app.use(require('./llenar_ponencia'));
|
||||
app.use(require('./llenar_cartel'));
|
||||
app.use(require('./descargar_ponencia'));
|
||||
app.use(require('./descargar_cartel'));
|
||||
|
||||
module.exports = app;
|
||||
+15
-2
@@ -25,9 +25,22 @@ function depurado(cadena) {
|
||||
|
||||
|
||||
app.get('/llenar_cartel', async(req, res) => {
|
||||
let mesa;
|
||||
let data = req.query;
|
||||
|
||||
console.log(req.query);
|
||||
try {
|
||||
let data = req.query;
|
||||
let cad = `select * from trabajo where mesa_tematica='${data.mesa}' and tipo_trabajo='cartel';`;
|
||||
let cad = `select nombre_mesa from admin where id_admin=${data.id_admin};`;
|
||||
let respuesta = await query(cad);
|
||||
mesa = respuesta[0].nombre_mesa;
|
||||
} catch (err) {
|
||||
console.log("afuera ", err);
|
||||
res.status(400).json({ error: true, msj: err, mas: data });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
let cad = `select * from trabajo where mesa_tematica='${mesa}' and tipo_trabajo='cartel';`;
|
||||
let respuesta = query(cad);
|
||||
respuesta.then(r => {
|
||||
res.status(200).json({ error: false, msj: "exito", dat: r });
|
||||
|
||||
@@ -25,9 +25,19 @@ function depurado(cadena) {
|
||||
|
||||
|
||||
app.get('/llenar_ponencia', async(req, res) => {
|
||||
let mesa;
|
||||
let data = req.query;
|
||||
try {
|
||||
let data = req.query;
|
||||
let cad = `select * from trabajo where mesa_tematica='${data.mesa}' and tipo_trabajo='ponencia';`;
|
||||
let cad = `select nombre_mesa from admin where id_admin=${data.id_admin};`;
|
||||
let respuesta = await query(cad);
|
||||
mesa = respuesta[0].nombre_mesa;
|
||||
} catch (err) {
|
||||
console.log("afuera ", err);
|
||||
res.status(400).json({ error: true, msj: err });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let cad = `select * from trabajo where mesa_tematica='${mesa}' and tipo_trabajo='ponencia';`;
|
||||
let respuesta = query(cad);
|
||||
respuesta.then(r => {
|
||||
res.status(200).json({ error: false, msj: "exito", dat: r });
|
||||
|
||||
@@ -29,7 +29,7 @@ app.post('/loggin_admin', async(req, res) => {
|
||||
let data = req.body;
|
||||
let usuario = depurado(data.usuario);
|
||||
//console.log(usuario, " lksaldksjdlasd");
|
||||
let cad = `select * from admin where usuario="${data.usuario}"`;
|
||||
let cad = `select * from admin where usuario='${data.usuario}'`;
|
||||
let respuesta = query(cad);
|
||||
// console.log(respuesta);
|
||||
respuesta.then(async r => {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const express = require('express');
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
var app = express()
|
||||
|
||||
function query(consulta) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
connection.query(`${consulta}`, (error, results, files) => {
|
||||
if (error) reject(error);
|
||||
resolve(results);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function depurado(cadena) {
|
||||
if (cadena != null) {
|
||||
cadena = cadena.replace(/'/g, "''");
|
||||
cadena = cadena.replace(/;/g, "m");
|
||||
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
app.post('/loggin_admin', async(req, res) => {
|
||||
try {
|
||||
let data = req.body;
|
||||
let usuario = depurado(data.correo);
|
||||
//console.log(usuario, " lksaldksjdlasd");
|
||||
let cad = `select * from persona where correo_electronico='${data.usuario}';`;
|
||||
let respuesta = query(cad);
|
||||
// console.log(respuesta);
|
||||
respuesta.then(async r => {
|
||||
// console.log(r, r.length);
|
||||
if (r.length == 0) {
|
||||
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
|
||||
return;
|
||||
} else {
|
||||
let pass = data.password;
|
||||
//console.log(pass);
|
||||
let n_pasword = await bcrypt.hash(pass, 10);
|
||||
//console.log(data);
|
||||
// console.log(n_pasword);
|
||||
let ban = bcrypt.compareSync(data.password, r[0].password);
|
||||
if (ban == true) {
|
||||
if (r[0].ponente == 1)
|
||||
res.status(200).json({ error: false, msj: "bienvenido", paricipacion: 'Ponente', id_persona: r[0].id_persona });
|
||||
else
|
||||
res.status(200).json({ error: false, msj: "bienvenido", paricipacion: 'Asistente', id_persona: r[0].id_persona });
|
||||
|
||||
return;
|
||||
} else {
|
||||
res.status(400).json({ error: false, msj: "Usuario o contraseña invalidos" });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
res.status(400).json({ error: true, msj: err });
|
||||
return;
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log("afuera ", err);
|
||||
res.status(400).json({ error: true, msj: err });
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = app
|
||||
+4
-1
@@ -2,8 +2,10 @@ const connection = require('../conf/connection.js');
|
||||
const express = require('express');
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
|
||||
var app = express()
|
||||
|
||||
|
||||
function query(consulta) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
connection.query(`${consulta}`, (error, results, files) => {
|
||||
@@ -23,6 +25,7 @@ function depurado(cadena) {
|
||||
app.post('/registro', async(req, res) => {
|
||||
let body = req.body;
|
||||
|
||||
|
||||
try {
|
||||
let n_correo = depurado(body.correo);
|
||||
let cad = `select * from persona where correo_electronico='${n_correo}';`;
|
||||
@@ -56,7 +59,7 @@ app.post('/registro', async(req, res) => {
|
||||
as = true;
|
||||
if (n_cuenta != null)
|
||||
n_cuenta = "'" + n_cuenta + "'";
|
||||
let n_pasword = await bcrypt.hash(body.pasword, 10);
|
||||
let n_pasword = await bcrypt.hash(body.password, 10);
|
||||
cad = `insert into persona values (null,'${n_nombre}', '${n_apellido_p}', '${n_apellido_m}', ${po}, ${as}, '${n_institucion}', '${body.comunidad}',
|
||||
'${body.situacion_academica}', '${body.pais}', ${n_cuenta}, '${n_correo}' ,'${n_pasword}', false );`;
|
||||
respuesta = query(cad);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
const connection = require('../conf/connection.js');
|
||||
const connection = require('../conf/connection.js');;
|
||||
const express = require('express');
|
||||
const fileUpload = require('express-fileupload');
|
||||
|
||||
|
||||
var app = express()
|
||||
app.use(fileUpload());
|
||||
|
||||
function query(consulta) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
@@ -24,6 +26,82 @@ app.post('/registro_ponencia', async(req, res) => {
|
||||
|
||||
|
||||
let pon = req.body.ponencia;
|
||||
if (req.body.ponencia == undefined || req.body.cartel == undefined)
|
||||
return res.status(400).json({ erro: true, msj: "falta el coampo ponencia o el campo cartel" });
|
||||
console.log(req.body.id_persona);
|
||||
|
||||
try {
|
||||
//console.log(req.files);
|
||||
if (req.files.ponencia != undefined) {
|
||||
let sampleFile = req.files.ponencia;
|
||||
let nombreCortado = sampleFile.name.split('.');
|
||||
let extencion = nombreCortado[nombreCortado.length - 1];
|
||||
let extensionValidas = ['docx', 'doc', 'odt'];
|
||||
|
||||
if (extensionValidas.indexOf(extencion) < 0) {
|
||||
return res.status(400).json({
|
||||
error: true,
|
||||
msj: "extencion invalida de ponencia"
|
||||
});
|
||||
}
|
||||
}
|
||||
if (req.files.cartel != undefined) {
|
||||
|
||||
let sampleFile = req.files.cartel;
|
||||
let nombreCortado = sampleFile.name.split('.');
|
||||
let extencion = nombreCortado[nombreCortado.length - 1];
|
||||
let extensionValidas = ['docx', 'doc', 'odt'];
|
||||
|
||||
if (extensionValidas.indexOf(extencion) < 0) {
|
||||
return res.status(400).json({
|
||||
error: true,
|
||||
msj: "extencion invalida de ponencia"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return res.status(400).json({
|
||||
error: true,
|
||||
msj: "error al verificar la extencion"
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
if (req.files.ponencia != undefined) {
|
||||
let sampleFile = req.files.ponencia;
|
||||
|
||||
sampleFile.mv(`files/ponencia-${req.body.id_persona}.docx`, function(err) {
|
||||
if (err)
|
||||
return res.status(500).send(err);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
res.status(400).json({ error: true, msj: "error al subir el archivo de ponencia", type: err });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (req.files.cartel) {
|
||||
let sampleFile = req.files.cartel;
|
||||
sampleFile.mv(`files/cartel-${req.body.id_persona}.docx`, function(err) {
|
||||
if (err)
|
||||
return res.status(500).send(err);
|
||||
});
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
res.status(400).json({ error: true, msj: "error al subir el archivo de ponencia", type: err });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (pon.autor_principal != undefined) {
|
||||
let n_autor_p = depurado(pon.autor_principal);
|
||||
|
||||
Reference in New Issue
Block a user