forked from services/mlmmj-light-web-ecg
Initial commit for release of version 1.0
This commit is contained in:
108
init.php
108
init.php
@@ -1,14 +1,103 @@
|
||||
<?php
|
||||
|
||||
// Loading config
|
||||
$config = file_get_contents("misc/config.txt");
|
||||
preg_match("/lists_path[\s]*=[\s]*(.*)/", $config, $lists_path);
|
||||
$lists_path = $lists_path[1];
|
||||
preg_match("/web_path[\s]*=[\s]*(.*)/", $config, $web_path);
|
||||
$web_path = $web_path[1];
|
||||
preg_match("/web_url[\s]*=[\s]*(.*)/", $config, $web_url);
|
||||
$web_url = $web_url[1];
|
||||
preg_match("/language[\s]*=[\s]*(.*)/", $config, $language);
|
||||
$language = $language[1];
|
||||
#$config = file_get_contents("misc/config.txt");
|
||||
#preg_match("/lists_path[\s]*=[\s]*(.*)/", $config, $lists_path);
|
||||
#$lists_path = $lists_path[1];
|
||||
#preg_match("/web_path[\s]*=[\s]*(.*)/", $config, $web_path);
|
||||
#$web_path = $web_path[1];
|
||||
#preg_match("/web_url[\s]*=[\s]*(.*)/", $config, $web_url);
|
||||
#$web_url = $web_url[1];
|
||||
#preg_match("/language[\s]*=[\s]*(.*)/", $config, $language);
|
||||
#$language = $language[1];
|
||||
|
||||
# -------------------------------------------------------------
|
||||
|
||||
# We want to have the config values in here to easily be able to extend it
|
||||
$lists_path = "/home/pacs/ecg00/users/mlmmj";
|
||||
$web_path = "/home/pacs/ecg00/users/mlmmj/doms/list.ecogood.org/htdocs-ssl/mlmmj-light-web-ecg/";
|
||||
$web_url = "https://list.ecogood.org/";
|
||||
$language = "en";
|
||||
$domain_global = "mlmmj";
|
||||
$current_version = "v1.0";
|
||||
$headline = "Manage your ECG mailing lists " . $current_version;
|
||||
$debug = true;
|
||||
$rc_webhook = "";
|
||||
|
||||
# -------------------------------------------------------------
|
||||
|
||||
# Custom PHP functions
|
||||
|
||||
# Registers user's activity in a file (audit log)
|
||||
function audit_log($action = "", $custom_input = "", $logfile = "audit_log.php")
|
||||
{
|
||||
# Initially set return value to false
|
||||
$return['success'] = false;
|
||||
$return['message'] = "";
|
||||
|
||||
# If $action is empty
|
||||
if ($action == "")
|
||||
{
|
||||
$action = "-empty-";
|
||||
}
|
||||
|
||||
# If $custom_input is empty
|
||||
if ($custom_input == "")
|
||||
{
|
||||
$custom_input = "-empty-";
|
||||
}
|
||||
|
||||
# Build the request string
|
||||
$request = date("Ymd-His") . " " . $_SESSION['username'] . "\n";
|
||||
$request .= "Action: " . $action . "\n";
|
||||
$request .= "Custom input: " . $custom_input . "\n";
|
||||
|
||||
# For security reasons don't include the GET/POST requests during login process as they might contain passwords
|
||||
if ($action != "login")
|
||||
{
|
||||
$request .= "\$_SESSION['array_lists_owned']: " . json_encode($_SESSION['array_lists_owned']) . "\n";
|
||||
$request .= "\$_GET: " . json_encode($_GET) . "\n";
|
||||
$request .= "\$_POST: " . json_encode($_POST) . "\n";
|
||||
}
|
||||
|
||||
$request .= "\$_SERVER['PHP_SELF']: " . basename($_SERVER['PHP_SELF']) . "\n";
|
||||
$request .= "\$_SERVER['REMOTE_ADDR']: " . basename($_SERVER['REMOTE_ADDR']) . "\n";
|
||||
$request .= "\n\n";
|
||||
|
||||
# Let's make sure the log file exists and is writable
|
||||
if (is_writable($logfile))
|
||||
{
|
||||
# We're opening $filename in append mode.
|
||||
if (!$handle = fopen($logfile, 'a')) {
|
||||
$return['message'] = "Cannot open file ($logfile)";
|
||||
}
|
||||
|
||||
// Write $somecontent to our opened file.
|
||||
if (fwrite($handle, $request) === FALSE) {
|
||||
$return['message'] = "Cannot write to file ($logfile)";
|
||||
}
|
||||
|
||||
$return['success'] = true;
|
||||
|
||||
fclose($handle);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['message'] = "The file $logfile is not writable.";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
# -------------------------------------------------------------
|
||||
|
||||
if ($debug)
|
||||
{
|
||||
error_reporting(E_ALL && ~E_NOTICE);
|
||||
ini_set("display_errors", 1);
|
||||
}
|
||||
|
||||
// Initializing Smarty
|
||||
require("misc/smarty_libs/Smarty.class.php");
|
||||
@@ -20,4 +109,5 @@ $smarty->setCacheDir("misc/smarty/cache");
|
||||
$smarty->setConfigDir("misc/smarty/configs");
|
||||
|
||||
session_start();
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user