more env files

master
Juan 3 years ago
parent 330e2176a6
commit 65c81de4ef

@ -2,6 +2,18 @@
header("Content-type: text/plain;charset=utf-8");
// curl :
// https://www.php.net/manual/fr/intro.curl.php
// curl basics
// https://weichie.com/blog/curl-api-calls-with-php/
// curl basics with auth
// https://weichie.com/blog/php-curl-api-calls-authentication/
// curl en fr
// https://analyse-innovation-solution.fr/publication/fr/php/curl-post-get-proxy-https
// guide du dévbutant
// https://rapidapi.com/blog/how-to-use-an-api-with-php/
// vars
$api_key = "bc1e13327f7f4876902d4bc45c30e102";
$api_url = "https://api.geoapify.com/v1/";

@ -2,8 +2,6 @@
//from : https://api.wordpress.org/secret-key/1.1/salt
define('AUTH_KEY', '2(QMu)jt|2!(9t]V!4SB/y,+T]LcvGZ8-sV@vS6RUgR!_]&S}{6/RZjAmLeW28On');
function get_client_ip()
{
$ip = null;

@ -0,0 +1,13 @@
# port du server node au démarrage
SERVER_PORT=4444
# informations de connexion à la base de donnée ...
# le server
DB_HOST=127.0.0.1
# le port
DB_PORT=3306
# user et password
DB_USR=test
DB_PWD=averylongpassword
# nom de la base
DB_NAME=thedatabasename

@ -10,10 +10,17 @@ var util = require('util');
// si on veut reste on "write"
var logfile = fs.createWriteStream(process.cwd() + '/server.log', { flags: 'w' });
console.log = function () {
logfile.write(util.format.apply(null, arguments) + '\n');
let args = Array.from(arguments);
args = args.map(function (value) {
datetime=new Date();
value="\n"+datetime.toLocaleString('fr-FR', {hour12: false}) + " - " + typeof(value) + " - " +value.toString();
return(value);
});
logfile.write(args.join(''));
process.stdout.write(util.format.apply(null, arguments) + '\n');
}
const server = http.createServer(function (request, response) {
parsedUrl = url.parse(request.url, false);
json_response(200,{status : "active"},response);
@ -41,7 +48,7 @@ fs.access(local_env_file, fs.constants.R_OK, (err) => {
server.listen(process.env.SERVER_PORT || 8080);
datetime=new Date();
console.log('server started at :'+datetime.toLocaleString('fr-FR', {hour12: false}));
console.log('server started at :'+datetime.toLocaleString('en-EN'),'server started at :'+datetime);
console.log("coucou",1,'server started at :'+datetime.toLocaleString('en-EN'),'server started at :'+datetime);
});
//usefull functions

@ -1,8 +1,16 @@
const http = require('http');
const url = require('url');
const fs = require('fs');
// load config file
const config = require(process.cwd() + '/config.json');
var config=null;
//if config.local.jsoon exists load it
if(fs.existsSync(process.cwd() + '/config.local.json')){
config = require(process.cwd() + '/config.local.json');
}
// else load normal config file
else {
config = require(process.cwd() + '/config.json');
}
function outputHTML5(status, response, content, title)
{
@ -25,12 +33,13 @@ function outputHTML5(status, response, content, title)
response.end();
}
//par defaut on se considère
let env = 'install';
var server = http.createServer(function (request, response) {
if(request.url === "/") {
content = config.staging.config_id;
outputHTML5(200,response,content,"Server info");
startup_args = process.argv.slice(2);
content = config[startup_args[0]].config_id;
outputHTML5(200,response,content,"Server info");
}
else {
outputHTML5(404,response,'Y\'a rien ici',"Oups");

Loading…
Cancel
Save