Commit f57250e2 authored by Moe's avatar Moe 😎

Add "codeTester" module (Not Complete)

- Merge test functions into main app and invoke based on 1 of 2 Methods.
- Method 1 : Add `"testMode":true` to conf.json to start Shinobi in Test Mode.
- Method 2 : run `node camera.js test` in the Shinobi folder.
- CTRL+C to exit process and cleanup test files.
+ Code cleanup and bug fixes (found while testing the codeTester module)
+ Update "Entire System Export"
+ Additional Extenders
+ Make Input Map default "0" instead of "0:0"
+ Remove extra Whitespace from LICENSE and update the "Modification of this Software Product.".
parent b8f6b528
......@@ -3,41 +3,41 @@ SHINOBI OPEN SOURCE SOFTWARE LICENSE AGREEMENT
Version 1, 04 June 2018
Copyright (C) 2018 [Shinobi Systems](https://shinobi.systems)
*We'll try to keep it simple. Thanks for using Shinobi Software!*
Definitions.
-----------
In this license, which also serves as a general End User License Agreement [EULA], the following
In this license, which also serves as a general End User License Agreement [EULA], the following
terms shall be interpreted by these definitions:
* "EULA" shall mean this End User Licence Agreement
* "Licensor" shall mean SHINOBI SYSTEMS
* "Licensee" shall mean YOU, or the organisation (if any) on whose behalf YOU are taking the EULA.
"SOFTWARE PRODUCTS" or "SOFTWARE" or "PRODUCTS" shall mean the Software Product this License is
included with and any additional modules or add-ons delivered by Shinobi Systems. The term
"SOFTWARE PRODUCTS" or "SOFTWARE" or "PRODUCTS" shall mean the Software Product this License is
included with and any additional modules or add-ons delivered by Shinobi Systems. The term
"SOFTWARE" includes, to the extent provided by SHINOBI SYSTEMS:
1) any revisions, updates and/or upgrades thereto;
2) any data, image or executable files, databases, data engines, computer software, or similar
2) any data, image or executable files, databases, data engines, computer software, or similar
items customarily used or distributed with computer software products;
3) anything in any form whatsoever intended to be used with or in conjunction with the SOFTWARE;
4) any associated media, documentation (including physical, electronic and on-line) and printed
4) any associated media, documentation (including physical, electronic and on-line) and printed
materials (the "Documentation").
Purpose of the Agreement.
-------------------------
**The Short**: Protect the rights of this Software Product and the LICENSOR.
**The Long**: The LICENSOR grants the LICENSEE a non-exclusive, non-transferable and perpetual
licence to use the SOFTWARE PRODUCTS listed therein and under the terms thereof. By accepting
the terms and conditions established in this agreement, the LICENSEE does not acquire any
ownership of copyright or other intellectual property rights in any part of the SOFTWARE
PRODUCTS. The LICENSEE is only entitled to use the SOFTWARE PRODUCTS in accordance with the
terms and conditions set forth by Shinobi Systems. By using the SOFTWARE PRODUCTS, the
**The Long**: The LICENSOR grants the LICENSEE a non-exclusive, non-transferable and perpetual
licence to use the SOFTWARE PRODUCTS listed therein and under the terms thereof. By accepting
the terms and conditions established in this agreement, the LICENSEE does not acquire any
ownership of copyright or other intellectual property rights in any part of the SOFTWARE
PRODUCTS. The LICENSEE is only entitled to use the SOFTWARE PRODUCTS in accordance with the
terms and conditions set forth by Shinobi Systems. By using the SOFTWARE PRODUCTS, the
LICENSEE agrees to accept the terms and conditions presented.
LICENSEE must purchase the applicable subscription in any other use case unless otherwise
granted. If the use case does not have a subscription applicable please contact a
LICENSEE must purchase the applicable subscription in any other use case unless otherwise
granted. If the use case does not have a subscription applicable please contact a
representative at support@shinobi.systems.
#### Commercial Uses
......@@ -50,48 +50,48 @@ representative at support@shinobi.systems.
- When used for research or educational purposes
- Testing Purposes
- Usage by Educational institutions
- Use for Emergency Services and facilties associated like Search and Rescue Services or
- Use for Emergency Services and facilties associated like Search and Rescue Services or
Ambulance Services
- Use in Health Care facility like a hospital or walk-in clinic
#### Support Services.
The Maintenance and Support Service shall be contracted and provided as per selected plan
The Maintenance and Support Service shall be contracted and provided as per selected plan
agreement, taxes will be included in all prices for Support Services.
Support Services will only provide support services as per the selected agreement.
This is not the entire agreement on support services. You must also review all agreements
This is not the entire agreement on support services. You must also review all agreements
provided with subscription plans provided.
#### Software Product Ownership.
This software is property of Shinobi Systems. LICENSEE must keep all copyright notices
This software is property of Shinobi Systems. LICENSEE must keep all copyright notices
unchanged.
#### Modification of this Software Product.
LICENSEE may modify code for personal use but must provide these changes upon request from
Shinobi Systems or an authorized Shinobi representative. LICENSEE may not alter or change
copyright notices. All code changes by LICENSEE shall fall under the copyright of Shinobi
LICENSEE may modify code for but must provide these changes upon request from
Shinobi Systems or an authorized Shinobi representative. LICENSEE may not alter or change
copyright notices. All code changes by LICENSEE shall fall under the copyright of Shinobi
Systems in the case code modified by LICENSEE is integrated into the official Shinobi code base.
#### Software Product Rebranding or "White-Labelling".
LICENSEE can remove the Shinobi branding from the front end but all copyright notices must
LICENSEE can remove the Shinobi branding from the front end but all copyright notices must
remain unchanged.
#### Software Product Contributions.
All contributed code becomes the property of Shinobi Systems. All contributors give permission
All contributed code becomes the property of Shinobi Systems. All contributors give permission
to Shinobi and Shinobi developers to use the code however it is seen fit.
#### Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
#### Changes to the Agreement.
Shinobi Systems reserves the right to change the license and set of terms at any time.
Continued use is agreement to those possible changes. Changes to this license will be provided
Shinobi Systems reserves the right to change the license and set of terms at any time.
Continued use is agreement to those possible changes. Changes to this license will be provided
in the commit history of the repository it is located in.
#### Legal Proceedings.
......@@ -100,7 +100,7 @@ All lawsuits must be filed at the Vancouver Court House.
Courthouse Vancouver Robson Square
800 Hornby St, Vancouver, BC V6Z 2C5
#### List of Included Software
#### List of Included Software
This list is completed to best of our knowledge.
......
......@@ -15,14 +15,16 @@ var loadLib = function(lib){
}
//process handlers
var s = loadLib('process')(process,__dirname)
//load extender functions
loadLib('extenders')(s)
//configuration loader
var config = loadLib('config')(s)
//language loader
var lang = loadLib('language')(s,config)
//code test module
loadLib('codeTester')(s,config,lang,io)
//basic functions
loadLib('basic')(s,config)
//load extender functions
loadLib('extenders')(s,config)
//video processing engine
loadLib('ffmpeg')(s,config,function(){
//database connection : mysql, sqlite3..
......
......@@ -204,8 +204,11 @@
"Backblaze Error": "Backblaze Error",
"Could not create Bucket.": "Could not create Bucket.",
"Amazon S3": "Amazon S3",
"Database": "Database",
"Database Not Found": "Database Not Found",
"User Not Found": "User Not Found",
"Save Links to Database": "Save Links to Database",
"Upload File": "Upload File",
"Bucket": "Bucket",
"Region": "Region",
"Use Global Amazon S3 Video Storage": "Use Global Amazon S3 Video Storage",
......
......@@ -35,6 +35,10 @@ module.exports = function(s,config,lang){
//check IP address of connecting user
var finish=function(user){
if(s.api[params.auth].ip.indexOf('0.0.0.0')>-1||s.api[params.auth].ip.indexOf(params.ip)>-1){
if(!user.lang){
var details = s.parseJSON(user.details).lang
user.lang = s.getDefinitonFile(user.details.lang) || s.copySystemDefaultLanguage()
}
cb(user);
}else{
failed();
......@@ -43,7 +47,10 @@ module.exports = function(s,config,lang){
//check if auth key is user's temporary session key
if(s.group[params.ke]&&s.group[params.ke].users&&s.group[params.ke].users[params.auth]){
s.group[params.ke].users[params.auth].permissions={};
cb(s.group[params.ke].users[params.auth]);
if(!s.group[params.ke].users[params.auth].lang){
s.group[params.ke].users[params.auth].lang = s.copySystemDefaultLanguage()
}
cb(s.group[params.ke].users[params.auth])
}else{
//check if key is already in memory to save query time
if(s.api[params.auth]&&s.api[params.auth].details){
......
......@@ -31,12 +31,14 @@ module.exports = function(s,config){
}
}
s.parseJSON = function(string){
var parsed
try{
string = JSON.parse(string)
}catch(err){
}
return string
if(!parsed)parsed = string
return parsed
}
s.stringJSON = function(json){
try{
......
var fs = require('fs');
var execSync = require('child_process').execSync;
module.exports = function(s,config,lang,io){
var onFFmpegLoaded = function(ffmpeg){
if(process.argv[2] && process.argv[2].indexOf('test') > -1){
config.testMode = true
}
if(config.testMode === true){
config.videosDir = s.mainDirectory + '/videosTest/'
config.port = 9999
if(config.childNodes && config.childNodes.enabled === true && config.childNodes.mode === 'master'){
config.childNodes.port = 9998
}
s.ffmpegFunctions = ffmpeg
}
}
var onBeforeDatabaseLoad = function(ffmpeg){
if(config.testMode === true){
try{
execSync('rm ' + s.mainDirectory + '/shinobi-test.sqlite')
}catch(err){
}
try{
require('sqlite3')
}catch(err){
execSync('npm install sqlite3 --unsafe-perm')
}
execSync('cp ' + s.mainDirectory + '/sql/shinobi.sample.sqlite ' + s.mainDirectory + '/shinobi-test.sqlite')
config.databaseType = 'sqlite3'
config.db = {
filename: s.mainDirectory + "/shinobi-test.sqlite"
}
}
}
var onProcessReady = function(){
if(config.testMode === true){
s.location.super = s.mainDirectory + '/super-test.json'
fs.writeFileSync(s.location.super,s.s([
{
"mail":"admin@shinobi.video",
"pass":"21232f297a57a5a743894a0e4a801fc3",
"tokens":[
"111"
]
}
],null,3))
setTimeout(function(){
require(s.mainDirectory + '/test/run.js')(s,config,lang,io)
},500)
}
}
var onProcessExit = function(){
if(config.testMode === true){
execSync('rm ' + s.mainDirectory + '/shinobi-test.sqlite')
execSync('rm ' + s.location.super)
execSync('rm -rf ' + config.videosDir)
console.log('---- Temporary Files Cleaned Up')
process.exit()
}
}
//attach event handlers
s.onFFmpegLoaded(onFFmpegLoaded)
s.onBeforeDatabaseLoad(onBeforeDatabaseLoad)
s.onProcessReady(onProcessReady)
s.onProcessExit(onProcessExit)
}
......@@ -51,6 +51,5 @@ module.exports = function(s){
if(config.childNodes.key === undefined)config.childNodes.key = [
'3123asdasdf1dtj1hjk23sdfaasd12asdasddfdbtnkkfgvesra3asdsd3123afdsfqw345'
];
return config
}
......@@ -98,4 +98,19 @@ module.exports = function(s,config){
s.onProcessReadyExtensions.push(callback)
}
//
s.onProcessExitExtensions = []
s.onProcessExit = function(callback){
s.onProcessExitExtensions.push(callback)
}
//
s.onBeforeDatabaseLoadExtensions = []
s.onBeforeDatabaseLoad = function(callback){
s.onBeforeDatabaseLoadExtensions.push(callback)
}
//
s.onFFmpegLoadedExtensions = []
s.onFFmpegLoaded = function(callback){
s.onFFmpegLoadedExtensions.push(callback)
}
//
}
......@@ -104,6 +104,9 @@ module.exports = function(s,config,onFinish){
ffmpeg.completeCheck = function(){
ffmpeg.checkVersion(function(){
ffmpeg.checkHwAccelMethods(function(){
s.onFFmpegLoadedExtensions.forEach(function(extender){
extender(ffmpeg)
})
onFinish(ffmpeg)
})
})
......@@ -132,7 +135,7 @@ module.exports = function(s,config,onFinish){
string += ' -map '+v.map
})
}else{
string += ' -map 0:0'
string += ' -map 0'
}
}
return string;
......
......@@ -7,6 +7,9 @@ module.exports = function(process,__dirname){
});
// [CTRL] + [C] = exit
process.on('SIGINT', function() {
s.onProcessExitExtensions.forEach(function(extender){
extender()
})
console.log('Shinobi is Exiting...')
process.exit();
});
......
module.exports = function(s,config){
s.onBeforeDatabaseLoadExtensions.forEach(function(extender){
extender(config)
})
//sql/database connection with knex
s.databaseOptions = {
client: config.databaseType,
......@@ -77,21 +80,43 @@ module.exports = function(s,config){
s.databaseEngine = require('knex')(s.databaseOptions)
}
s.preQueries = function(){
//add Cloud Videos table, will remove in future
s.sqlQuery('CREATE TABLE IF NOT EXISTS `Cloud Videos` (`mid` varchar(50) NOT NULL,`ke` varchar(50) DEFAULT NULL,`href` text NOT NULL,`size` float DEFAULT NULL,`time` timestamp NULL DEFAULT NULL,`end` timestamp NULL DEFAULT NULL,`status` int(1) DEFAULT \'0\' COMMENT \'0:Complete,1:Read,2:Archive\',`details` text) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;',[],function(err){
// if(err)console.log(err)
var knex = s.databaseEngine
var mySQLtail = ''
if(config.databaseType === 'mysql'){
mySQLtail = ' ENGINE=InnoDB DEFAULT CHARSET=utf8'
}
//add Presets table and modernize
var createPresetsTableQuery = 'CREATE TABLE IF NOT EXISTS `Presets` ( `ke` varchar(50) DEFAULT NULL, `name` text, `details` text, `type` varchar(50) DEFAULT NULL);'
s.sqlQuery( createPresetsTableQuery + mySQLtail + ';',[],function(err){
if(err)console.error(err)
if(config.databaseType === 'sqlite3'){
var aQuery = "ALTER TABLE Presets RENAME TO _Presets_old;"
aQuery += createPresetsTableQuery
aQuery += "INSERT INTO Presets (`ke`, `name`, `details`, `type`) SELECT `ke`, `name`, `details`, `type` FROM _Presets_old;COMMIT;DROP TABLE _Presets_old;"
}else{
s.sqlQuery('ALTER TABLE `Presets` CHANGE COLUMN `type` `type` VARCHAR(50) NULL DEFAULT NULL AFTER `details`;',[],function(err){
if(err)console.error(err)
},true)
}
},true)
//add monitorStates to Preset ENUM
s.sqlQuery('ALTER TABLE `Presets` CHANGE COLUMN `type` `type` VARCHAR(50) NULL DEFAULT NULL AFTER `details`;',[],function(err){
// if(err)console.log(err)
//add Cloud Videos table, will remove in future
s.sqlQuery('CREATE TABLE IF NOT EXISTS `Cloud Videos` (`mid` varchar(50) NOT NULL,`ke` varchar(50) DEFAULT NULL,`href` text NOT NULL,`size` float DEFAULT NULL,`time` timestamp NULL DEFAULT NULL,`end` timestamp NULL DEFAULT NULL,`status` int(1) DEFAULT \'0\',`details` text)' + mySQLtail + ';',[],function(err){
if(err)console.error(err)
},true)
//create Files table
s.sqlQuery('CREATE TABLE IF NOT EXISTS `Files` (`ke` varchar(50) NOT NULL,`mid` varchar(50) NOT NULL,`name` tinytext NOT NULL,`size` float NOT NULL DEFAULT \'0\',`details` text NOT NULL,`status` int(1) NOT NULL DEFAULT \'0\') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;',[],function(err){
// if(err)console.log(err)
var createFilesTableQuery = "CREATE TABLE IF NOT EXISTS `Files` (`ke` varchar(50) NOT NULL,`mid` varchar(50) NOT NULL,`name` tinytext NOT NULL,`size` float NOT NULL DEFAULT '0',`details` text NOT NULL,`status` int(1) NOT NULL DEFAULT '0',`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"
s.sqlQuery(createFilesTableQuery + mySQLtail + ';',[],function(err){
if(err)console.error(err)
//add time column to Files table
s.sqlQuery('ALTER TABLE `Files` ADD COLUMN `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `status`;',[],function(err){
// if(err)console.log(err)
},true)
if(config.databaseType === 'sqlite3'){
var aQuery = "ALTER TABLE Files RENAME TO _Files_old;"
aQuery += createPresetsTableQuery
aQuery += "INSERT INTO Files (`ke`, `mid`, `name`, `details`, `size`, `status`, `time`) SELECT `ke`, `mid`, `name`, `details`, `size`, `status`, `time` FROM _Files_old;COMMIT;DROP TABLE _Files_old;"
}else{
s.sqlQuery('ALTER TABLE `Files` ADD COLUMN `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `status`;',[],function(err){
if(err)console.error(err)
},true)
}
},true)
delete(s.preQueries)
}
......
......@@ -4,12 +4,16 @@ var moment = require('moment');
var crypto = require('crypto');
var exec = require('child_process').exec;
var execSync = require('child_process').execSync;
module.exports = function(s,config,lang,io){
module.exports = function(s,config,lang,io,processReady){
console.log('FFmpeg version : '+s.ffmpegVersion)
console.log('Node.js version : '+execSync("node -v"))
s.processReady = function(){
s.systemLog(lang.startUpText5)
process.send('ready')
s.onProcessReadyExtensions.forEach(function(extender){
extender(true)
})
if(processReady)processReady()
}
var loadedAccounts = []
var loadMonitors = function(callback){
......
......@@ -21,10 +21,10 @@ module.exports = function(s,config,lang,app){
return
}
var form = s.getPostData(req)
var uid = s.getPostData(req,'uid',false)
var mail = s.getPostData(req,'mail',false)
var uid = form.uid || s.getPostData(req,'uid',false)
var mail = form.mail || s.getPostData(req,'mail',false)
if(form){
var keys = Object.keys(form)
var keys = ['details']
var condition = []
var value = []
keys.forEach(function(v){
......@@ -68,8 +68,9 @@ module.exports = function(s,config,lang,app){
s.closeJsonResponse(res,endData)
return
}
var uid = s.getPostData(req,'uid',false)
var mail = s.getPostData(req,'mail',false)
var form = s.getPostData(req)
var uid = form.uid || s.getPostData(req,'uid',false)
var mail = form.mail || s.getPostData(req,'mail',false)
s.sqlQuery('DELETE FROM Users WHERE uid=? AND ke=? AND mail=?',[uid,req.params.ke,mail])
s.sqlQuery("SELECT * FROM API WHERE ke=? AND uid=?",[req.params.ke,uid],function(err,rows){
if(rows && rows[0]){
......@@ -132,6 +133,12 @@ module.exports = function(s,config,lang,app){
uid: newId,
mail: form.mail
},'ADM_'+req.params.ke)
endData.user = {
details: s.parseJSON(details),
ke: req.params.ke,
uid: newId,
mail: form.mail
}
}
res.end(s.prettyPrint(endData))
})
......@@ -266,6 +273,7 @@ module.exports = function(s,config,lang,app){
},'GRP_' + req.params.ke)
endData.ok = true
}
endData.api = insert
s.closeJsonResponse(res,endData)
})
}else{
......@@ -366,7 +374,7 @@ module.exports = function(s,config,lang,app){
/**
* API : Administrator : Get Monitor State Presets List
*/
app.get([
app.all([
config.webPaths.apiPrefix+':auth/monitorStates/:ke',
config.webPaths.adminApiPrefix+':auth/monitorStates/:ke'
],function (req,res){
......
......@@ -288,6 +288,7 @@ module.exports = function(s,config,lang,app){
]
)
s.tx({f:'add_account',details:form.details,ke:form.ke,uid:form.uid,mail:form.mail},'$')
endData.user = Object.assign(form,{})
//init user
s.loadGroup(form)
}
......@@ -324,7 +325,7 @@ module.exports = function(s,config,lang,app){
r = r[0]
var details = JSON.parse(r.details)
if(form.pass && form.pass !== ''){
if(form.pass === form.password_again){
if(form.pass === form.password_again || form.pass_again){
form.pass = s.createHash(form.pass);
}else{
endData.msg = lang["Passwords Don't Match"]
......@@ -335,11 +336,18 @@ module.exports = function(s,config,lang,app){
delete(form.pass);
}
delete(form.password_again);
delete(form.pass_again);
var keys = Object.keys(form)
var set = []
var values = []
keys.forEach(function(v,n){
if(set==='ke'||set==='password_again'||!form[v]){return}
if(
set === 'ke' ||
!form[v]
){
//skip
return
}
set.push(v+'=?')
if(v === 'details'){
form[v] = s.stringJSON(Object.assign(details,s.parseJSON(form[v])))
......@@ -360,6 +368,9 @@ module.exports = function(s,config,lang,app){
}
close()
})
}else{
endData.msg = lang['User Not Found']
close()
}
})
}else{
......@@ -413,35 +424,46 @@ module.exports = function(s,config,lang,app){
*/
app.all(config.webPaths.superApiPrefix+':auth/export/system', function (req,res){
s.superAuth(req.params,function(resp){
s.systemLog('Copy of the Database Exported',{
by: resp.$user.mail,
ip: resp.ip
})
var endData = {
ok : true
}
s.sqlQuery('SELECT * FROM Users',[],function(err,users){
s.sqlQuery('SELECT * FROM Monitors',[],function(err,monitors){
s.sqlQuery('SELECT * FROM API',[],function(err,api){
s.sqlQuery('SELECT * FROM Videos',[],function(err,videos){
s.sqlQuery('SELECT * FROM Logs',[],function(err,logs){
s.sqlQuery('SELECT * FROM Files',[],function(err,files){
s.sqlQuery('SELECT * FROM Presets',[],function(err,presets){
s.sqlQuery('SELECT * FROM `Cloud Videos`',[],function(err,cloudVideos){
endData.database = {
"API": api,
"Users": users,
"Monitors": monitors,
"Videos": videos,
"Presets": presets,
"Logs": logs,
"Files": files,
"Cloud Videos": cloudVideos
}
s.closeJsonResponse(res,endData)
})
})
})
})
// var database = s.getPostData(req,'database')
endData.database = {}
var tableNames = [
'Users',
'Monitors',
'API',
'Videos',
'Cloud Videos',
'Logs',
'Files',
'Presets',
]
var completedTables = 0
var tableExportLoop = function(callback){
var tableName = tableNames[completedTables]
if(tableName){
var tableIsSelected = s.getPostData(req,tableName) == 1
if(tableIsSelected){
s.sqlQuery('SELECT * FROM `' + tableName +'`',[],function(err,dataRows){
endData.database[tableName] = dataRows
++completedTables
tableExportLoop(callback)
})
})
})
}else{
++completedTables
tableExportLoop(callback)
}
}else{
callback()
}
}
tableExportLoop(function(){
s.closeJsonResponse(res,endData)
})
},res,req)
})
......@@ -453,9 +475,11 @@ module.exports = function(s,config,lang,app){
var endData = {
ok : false
}
console.log(req.files)
// insert data
var data = s.getPostData(req)
var database = s.getPostData(req,'database')
if(data.database)database = data.database
if(data && data.database)database = data.database
if(database){
var rowsExistingAlready = {}
var countOfRowsInserted = {}
......@@ -593,7 +617,6 @@ module.exports = function(s,config,lang,app){
s.closeJsonResponse(res,endData)
})
}else{
endData.database = lang['Database Not Found']
endData.msg = lang['Database Not Found']
s.closeJsonResponse(res,endData)
}
......
//
// Shinobi
// Copyright (C) 2016 Moe Alam, moeiscool
//
//
// # Donate
//
// If you like what I am doing here and want me to continue please consider donating :)
// PayPal : paypal@m03.ca
//
var io = new (require('socket.io'))()
//library loader
var loadLib = function(lib){
return require(__dirname+'/libs/'+lib+'.js')
}
//process handlers
var s = loadLib('process')(process,__dirname)
//configuration loader
var config = loadLib('config')(s)
//********* test.js >
config.port = 9999
if(config.childNodes && config.childNodes.enabled === true && config.childNodes.mode === 'master'){
config.childNodes.port = 9998
}
//********* test.js />
//language loader
var lang = loadLib('language')(s,config)
//basic functions
loadLib('basic')(s,config)
//load extender functions
loadLib('extenders')(s,config)
//video processing engine
loadLib('ffmpeg')(s,config,function(ffmpeg){
//********* test.js >
s.ffmpegFunctions = ffmpeg
//********* test.js />
//database connection : mysql, sqlite3..
loadLib('sql')(s,config)
//working directories : videos, streams, fileBin..
loadLib('folders')(s,config)
//authenticator functions : API, dashboard login..
loadLib('auth')(s,config,lang)
//express web server with ejs
var app = loadLib('webServer')(s,config,lang,io)
//web server routes : page handling..
loadLib('webServerPaths')(s,config,lang,app)
//web server routes for streams : streams..
loadLib('webServerStreamPaths')(s,config,lang,app)
//web server admin routes : create sub accounts, share monitors, share videos
loadLib('webServerAdminPaths')(s,config,lang,app)
//web server superuser routes : create admin accounts and manage system functions
loadLib('webServerSuperPaths')(s,config,lang,app)
//websocket connection handlers : login and streams..
loadLib('socketio')(s,config,lang,io)
//user and group functions
loadLib('user')(s,config)
//monitor/camera handlers
loadLib('monitor')(s,config,lang)
//event functions : motion, object matrix handler
loadLib('events')(s,config,lang)
//built-in detector functions : pam-diff..
loadLib('detector')(s,config)
//recording functions
loadLib('videos')(s,config,lang)
//plugins : websocket connected services..
loadLib('plugins')(s,config,lang)
//health : cpu and ram trackers..
loadLib('health')(s,config,lang,io)
//cluster module
loadLib('childNode')(s,config,lang,app,io)
//cloud uploaders : amazon s3, webdav, backblaze b2..
loadLib('cloudUploaders')(s,config,lang)
//notifiers : discord..
loadLib('notification')(s,config,lang)
//on-start actions, daemon(s) starter
require(__dirname+'/test/run.js')(s,config,lang,app,io)
})
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment