mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
callbook config install
This commit is contained in:
@@ -14,7 +14,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
$config['app_name'] = "Wavelog";
|
||||
$config['directory'] = "/%directory%";
|
||||
$config['callbook'] = "hamqth"; // Options are hamqth or qrz
|
||||
$config['callbook'] = "%callbook%"; // Options are hamqth or qrz
|
||||
|
||||
$config['datadir'] = null; // default to install directory
|
||||
|
||||
@@ -43,8 +43,8 @@ $config['display_freq'] = false;
|
||||
| 'use_fullname' Get full names from QRZ, may not be GDPR compliant
|
||||
*/
|
||||
|
||||
$config['qrz_username'] = "";
|
||||
$config['qrz_password'] = "";
|
||||
$config['qrz_username'] = "%qrz_username%";
|
||||
$config['qrz_password'] = "%qrz_password%";
|
||||
$config['use_fullname'] = false;
|
||||
|
||||
/*
|
||||
@@ -55,8 +55,8 @@ $config['use_fullname'] = false;
|
||||
| 'hamqth_username' HamQTH user login
|
||||
| 'hamqth_password' HamQTH user password
|
||||
*/
|
||||
$config['hamqth_username'] = "";
|
||||
$config['hamqth_password'] = "";
|
||||
$config['hamqth_username'] = "%hamqth_username%";
|
||||
$config['hamqth_password'] = "%hamqth_password%";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Core {
|
||||
class Core
|
||||
{
|
||||
|
||||
// Function to validate the post data
|
||||
function validate_post($data)
|
||||
@@ -9,118 +10,178 @@ class Core {
|
||||
$counter = 0;
|
||||
|
||||
// Validate the hostname
|
||||
if(isset($data['db_hostname']) AND !empty($data['db_hostname'])) {
|
||||
if (isset($data['db_hostname']) and !empty($data['db_hostname'])) {
|
||||
$counter++;
|
||||
}
|
||||
// Validate the username
|
||||
if(isset($data['db_username']) AND !empty($data['db_username'])) {
|
||||
if (isset($data['db_username']) and !empty($data['db_username'])) {
|
||||
$counter++;
|
||||
}
|
||||
// Validate the password
|
||||
if(isset($data['db_password']) AND !empty($data['db_password'])) {
|
||||
// pass
|
||||
if (isset($data['db_password']) and !empty($data['db_password'])) {
|
||||
// pass
|
||||
}
|
||||
// Validate the database
|
||||
if(isset($data['db_name']) AND !empty($data['db_name'])) {
|
||||
if (isset($data['db_name']) and !empty($data['db_name'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
if($data['directory'] != "") {
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].$data['directory'])) {
|
||||
if ($data['directory'] != "") {
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $data['directory'])) {
|
||||
//pass folders real
|
||||
$counter++;
|
||||
} else {
|
||||
echo "Directory ".$data['directory']." cannot be found";
|
||||
echo "Directory " . $data['directory'] . " cannot be found";
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Check if all the required fields have been entered
|
||||
if($counter == '4') {
|
||||
return true;
|
||||
// Validate First Name
|
||||
if (isset($_POST['firstname']) && !empty($_POST['firstname'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Validate Last Name
|
||||
if (isset($_POST['lastname']) && !empty($_POST['lastname'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Validate Username
|
||||
if (isset($_POST['username']) && !empty($_POST['username'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Validate Callsign
|
||||
if (isset($_POST['callsign']) && !empty($_POST['callsign'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Validate Password
|
||||
if (isset($_POST['password']) && !empty($_POST['password'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Validate Locator
|
||||
if (isset($_POST['userlocator']) && !empty($_POST['userlocator'])) {
|
||||
$locator = $_POST['userlocator'];
|
||||
if (preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}$/', $locator)) {
|
||||
$counter++;
|
||||
} else {
|
||||
$errors[] = "Invalid Maidenhead Locator format.";
|
||||
}
|
||||
} else {
|
||||
$errors[] = "Locator is required.";
|
||||
}
|
||||
else {
|
||||
|
||||
// Validate Confirm Password
|
||||
if (isset($_POST['cnfm_password']) && !empty($_POST['cnfm_password'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Validate Email Address
|
||||
if (isset($_POST['user_email']) && filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$counter++;
|
||||
} else {
|
||||
$errors[] = "Invalid Email Address.";
|
||||
}
|
||||
|
||||
// Validate Timezone
|
||||
if (isset($_POST['timezone']) && is_numeric($_POST['timezone'])) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// Check if all the required fields have been entered
|
||||
if ($counter == '13') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to show an error
|
||||
function show_message($type,$message) {
|
||||
function show_message($type, $message)
|
||||
{
|
||||
return $message;
|
||||
}
|
||||
|
||||
// Function to write the config file
|
||||
function write_config($data) {
|
||||
function write_config($data)
|
||||
{
|
||||
|
||||
// Config path
|
||||
$template_path = 'config/database.php';
|
||||
$output_path = $_SERVER['DOCUMENT_ROOT'].$data['directory'].'/application/config/database.php';
|
||||
$output_path = $_SERVER['DOCUMENT_ROOT'] . $data['directory'] . '/application/config/database.php';
|
||||
|
||||
// Open the file
|
||||
$database_file = file_get_contents($template_path);
|
||||
|
||||
$new = str_replace("%HOSTNAME%",$data['db_hostname'],$database_file);
|
||||
$new = str_replace("%USERNAME%",$data['db_username'],$new);
|
||||
$new = str_replace("%PASSWORD%",$data['db_password'],$new);
|
||||
$new = str_replace("%DATABASE%",$data['db_name'],$new);
|
||||
$new = str_replace("%HOSTNAME%", $data['db_hostname'], $database_file);
|
||||
$new = str_replace("%USERNAME%", $data['db_username'], $new);
|
||||
$new = str_replace("%PASSWORD%", $data['db_password'], $new);
|
||||
$new = str_replace("%DATABASE%", $data['db_name'], $new);
|
||||
|
||||
// Write the new database.php file
|
||||
$handle = fopen($output_path,'w+');
|
||||
$handle = fopen($output_path, 'w+');
|
||||
|
||||
// Chmod the file, in case the user forgot
|
||||
@chmod($output_path,0777);
|
||||
@chmod($output_path, 0777);
|
||||
|
||||
// Verify file permissions
|
||||
if(is_writable($output_path)) {
|
||||
if (is_writable($output_path)) {
|
||||
|
||||
// Write the file
|
||||
if(fwrite($handle,$new)) {
|
||||
if (fwrite($handle, $new)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to write the config file
|
||||
function write_configfile($data) {
|
||||
function write_configfile($data)
|
||||
{
|
||||
|
||||
// Config path
|
||||
$template_path = 'config/config.php';
|
||||
$output_path = $_SERVER['DOCUMENT_ROOT'].$data['directory'].'/application/config/config.php';
|
||||
$output_path = $_SERVER['DOCUMENT_ROOT'] . $data['directory'] . '/application/config/config.php';
|
||||
|
||||
// Open the file
|
||||
$database_file = file_get_contents($template_path);
|
||||
|
||||
$new = str_replace("%baselocator%",$data['locator'],$database_file);
|
||||
$new = str_replace("%websiteurl%",$data['websiteurl'],$new);
|
||||
$new = str_replace("%directory%",$data['directory'],$new);
|
||||
$new = str_replace("%baselocator%", $data['locator'], $database_file);
|
||||
$new = str_replace("%websiteurl%", $data['websiteurl'], $new);
|
||||
$new = str_replace("%directory%", $data['directory'], $new);
|
||||
$new = str_replace("%callbook%", $data['global_call_lookup'], $new);
|
||||
if ($data['global_call_lookup'] == 'qrz') {
|
||||
$new = str_replace("%qrz_username%", $data['callbook_username'], $new);
|
||||
$new = str_replace("%qrz_password%", $data['callbook_password'], $new);
|
||||
} else {
|
||||
$new = str_replace("%hamqth_username%", $data['callbook_username'], $new);
|
||||
$new = str_replace("%hamqth_password%", $data['callbook_password'], $new);
|
||||
}
|
||||
|
||||
// Write the new config.php file
|
||||
$handle = fopen($output_path,'w+');
|
||||
$handle = fopen($output_path, 'w+');
|
||||
|
||||
// Chmod the file, in case the user forgot
|
||||
@chmod($output_path,0777);
|
||||
@chmod($output_path, 0777);
|
||||
|
||||
// Verify file permissions
|
||||
if(is_writable($output_path)) {
|
||||
if (is_writable($output_path)) {
|
||||
|
||||
// Write the file
|
||||
if(fwrite($handle,$new)) {
|
||||
if (fwrite($handle, $new)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user