Read database connection from config file

This commit is contained in:
root
2019-02-27 17:39:20 +01:00
parent 1e0cec945c
commit 2040b7be39
5 changed files with 31 additions and 14 deletions

View File

@@ -1,10 +1,13 @@
<?php
require_once 'vendor/autoload.php';
$cfg = include('accred_config.php');
session_start();
$mode = $_POST['mode'];
openlog('ACCRED', LOG_PID, LOG_LOCAL0);
if($mode=='logout') {
$mysqli = new mysqli("localhost", "caribanaaccred", "welcome99", "caribanaaccred");
$mysqli = new mysqli($cfg['host'], $cfg['user'],$cfg['pass'], $cfg['name']);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
@@ -42,7 +45,7 @@ if ($payload) {
// Is this user admin
$_SESSION['admin'] = '';
// Set to 1 to allow normal users to add new entries en edit existing
// $_SESSION['allowedit'] = 1;
$_SESSION['allowedit'] = 1;
if( array_key_exists($userid, $admins)) {
$_SESSION['admin'] = 1;
}