Skip to content

Commit

Permalink
*.ini configuration update
Browse files Browse the repository at this point in the history
Finally! More and more libraries are using their own configuration files! 😃
  • Loading branch information
AidenF0X committed Nov 15, 2021
1 parent 9ae2317 commit 30a0612
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 140 deletions.
40 changes: 23 additions & 17 deletions foxxey/actions/module_authorise.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-----------------------------------------------------
File: authorise.class.php
-----------------------------------------------------
Verssion: 0.1.17.6 Exp
Verssion: 0.1.19.6 Post Exp
-----------------------------------------------------
Usage: Authorising and using HWID
=====================================================
Expand Down Expand Up @@ -54,15 +54,30 @@ class Authorise {
private $userGroup;
private $regDate;

/* CONFIG */
private $mdlName = 'authorise';
private $authModules = array();
private $defaultConfig = array('authorise' =>
array(
'checkHWID' => true,
'geoIPcheck' => true,
'useAntiBrute' => true,
'getBalance' => true,
'foxChecking' => true,
));

/**
* Authorise constructor.
* @param $login
* @param $pass
* @param $HWID
*/
function __construct($login, $pass, $HWID, $launcherDB, $userDataDB, $ip){
$conf = conff::confGen($this->mdlName, $this->defaultConfig);
$this->authModules = $conf->readInIarray();

global $config;
Authorise::IncludeAuthModules();
filesInDir::getIncludes($this->mdlName);
try {
$this->webSiteDB = new db($config['db_user'], $config['db_pass'], $config['db_database'], $config['db_host']);
} catch(PDOException $pe) {
Expand Down Expand Up @@ -97,7 +112,7 @@ public function logIn() {
exit('{"message": "'.$message['dataNotIsset'].'"}');
} else {
//Getting user login location
if($config['geoIPcheck'] === true) {
if($this->authModules['geoIPcheck']) {
if(class_exists('geoPlugin')) {
$geoplugin = new geoPlugin($this->ip);
if($geoplugin->countryCode !== null) {
Expand Down Expand Up @@ -126,7 +141,7 @@ public function logIn() {
}

// Checking HWID
if($config['checkHWID'] === true) {
if($this->authModules['checkHWID']) {
if(class_exists('HWID')) {
$hardwareCheck = new HWID($this->login, $this->HWID, $this->launcherDB, $config['HWIDdebug']);
$HWIDuser = $hardwareCheck->getUserNameByHWID() ?? $this->HWID;
Expand All @@ -143,7 +158,7 @@ public function logIn() {
//==============

if(!$this->correctLogin) { //If Login is incorrect
if($config['useAntiBrute'] === true) {
if($this->authModules['useAntiBrute']) {
$antiBrute = new antiBrute($this->ip, $this->launcherDB, $config['antiBruteDebug']);
}
static::$LoggerAuth->WriteLine('Incorrect login for '.$this->ip.' as '.$this->login.' using `'.$this->pass.'` Bruting by '.$HWIDuser);
Expand All @@ -163,7 +178,7 @@ public function logIn() {
$this->regDate = json_decode(mainSite::getUserData($this->login, 'reg_date')) -> reg_date ?? null;

// Getting Balance
if($config['getBalance'] === true) {
if($this->authModules['getBalance']) {
if(class_exists('userbalance')) {
$balance = new userbalance($this->login, 'realmoney', false);
$units = $balance->getUserBalance();
Expand All @@ -175,7 +190,7 @@ public function logIn() {
//================

// Fox checking
if($config['foxChecking'] === true) {
if($this->authModules['foxChecking']) {
if(class_exists('foxCheck')) {
$checkFox = new foxCheck($this->login, $config['foxCheckDebug'], $this->userDataDB, static::$LoggerAuth);
if($checkFox->checkFox() === true){
Expand Down Expand Up @@ -220,14 +235,5 @@ private function incorrectPass($login, $HWIDuser) {
$query = "INSERT INTO `wrongPass`(`login`, `realLogin`) VALUES ('".$login."', '".$HWIDuser."')";
$this->launcherDB::run($query);
}

//Will be replaced
private static function IncludeAuthModules(){
global $config;
$modulesDir = INCDIR.'authorise';
if(!is_dir($modulesDir)){
mkdir($modulesDir);
}
functions::includeModules($modulesDir, $config['modulesDebug']);
}

}
24 changes: 9 additions & 15 deletions foxxey/actions/module_startUpSound.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-----------------------------------------------------
File: startUpSound.class.php
-----------------------------------------------------
Version: 0.3.35.12 Insane
Version: 0.3.36.12 Insane
-----------------------------------------------------
Usage: Current Event Sound generation
=====================================================
Expand Down Expand Up @@ -41,10 +41,9 @@
class startUpSound {

/* Base utils */
private $opdl = 'startupsound';
private $config = array();

private $cacheFilePath = ETC.'startupsound.timetable';
private static $serverVersion = '0.3.35.12 Insane';
private static $serverVersion = '0.3.36.12 Insane';
private static $AbsolutesoundPath;
private static $currentDate = CURRENT_DATE;
private static $musMountPoint = 'mus';
Expand All @@ -58,6 +57,10 @@ class startUpSound {
private static $soundFilesNum = 0;
private static $easter = "";
private static $debug = false;

/*CONFIG*/
private $mdlName = 'startupsound';
private $config = array();
private $defaultConfig = array('startupsound' =>
array(
'debug' => false,
Expand Down Expand Up @@ -176,7 +179,7 @@ class startUpSound {
//Initialisation
function __construct() {

$conf = conff::confGen($this->opdl, $this->defaultConfig);
$conf = conff::confGen($this->mdlName, $this->defaultConfig);
$this->config = $conf->readInIarray();

$dateExploded = explode ('.',CURRENT_DATE);
Expand All @@ -188,7 +191,7 @@ function __construct() {
$this->eventsArray = file::efile($this->cacheFilePath, true, $this->eventsArray)['content'];
}

startUpSound::IncludestartUpSoundModules();
filesInDir::getIncludes($this->mdlName);
startUpSound::$AbsolutesoundPath = $this->config['mountDir'];
startUpSound::$debug = $debug ?? false;
$this->selectCurrentEvent($this->dayToday, $this->monthToday);
Expand Down Expand Up @@ -592,13 +595,4 @@ private function seasonNow(){

}

private static function IncludestartUpSoundModules(){
global $config;
$modulesDir = INCDIR.'startupsound';
if(!is_dir($modulesDir)){
mkdir($modulesDir);
}
functions::includeModules($modulesDir, $config['modulesDebug']);
}

}
62 changes: 27 additions & 35 deletions foxxey/actions/module_startUpSound.classExp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-----------------------------------------------------
File: startUpSound.class.php
-----------------------------------------------------
Version: 1.2.0.0 Experimental
Version: 1.2.1.0 Experimental
-----------------------------------------------------
Usage: Current Event Sound generation
=====================================================
Expand All @@ -28,15 +28,15 @@
class startUpSound {

/* IO Utils */
private $cacheFilePath = ETC.'startUpSound.timetable';
private $cacheFilePath = ETC.'startupsound.timetable';
private $AbsolutePath;
private $musMountPoint = 'mus';
private $sndMountPoint = 'snd';
private $musFilesNum = 0;
private $sndFilesNum = 0;

/* Kernel settings */
private $serverVersion = '1.2.0.0 Experimental';
private $serverVersion = '1.2.1.0 Experimental';
private $eventNow = 'common';
private $musPerEvent = true;
private $useDayTime = false; //Use DayTime snd? (Morning, Day, Evening, Night)
Expand Down Expand Up @@ -149,6 +149,19 @@ class startUpSound {
private $sleepTime;
private $additionalInfo = 'NoData';

/*CONFIG*/
private $mdlName = 'startupsound';
private $config = array();
private $defaultConfig = array('startupsound' =>
array(
'debug' => false,
'mountDir' => SITE_ROOT."/etc/startUpSoundRepo",
'enableVoice' => true,
'enableMusic' => true,
'easterMusRarity' => 1000,
'easterSndRarity' => 1
));

/* Debug style */
//background: url('data:image/png;base64,') no-repeat;
private $pageStyle = "<style>
Expand All @@ -175,24 +188,14 @@ class startUpSound {
private $audioGenStyle = 'border: 1px solid black; padding: 5px; border-radius: 10px; width: fit-content; margin: 15px 2px;';

function __construct($debug = false){
global $config;
$this->AbsolutePath = $config['mountDir'];
$conf = conff::confGen($this->mdlName, $this->defaultConfig);
$this->config = $conf->readInIarray();
$this->AbsolutePath = $this->config['mountDir'];
$this->debug = $debug;
$this->fillDate(CURRENT_DATE);
$this->IncludestartUpSoundModules();

filesInDir::getIncludes($this->mdlName);
$this->eventsArray = file::efile($this->cacheFilePath, true, $this->eventsArray)['content'];


if(!file_exists($this->cacheFilePath)){
$this->WriteFile();
} else {
if(is_array($this->readEventFile())){
$this->eventsArray = $this->readEventFile();
} else {
$this->WriteFile();
$this->eventsArray = $this->readEventFile();
}
}
$this->genAudio('mus');
$this->genAudio('snd');
$this->selectCurrentEvent($this->dayToday, $this->monthToday);
Expand Down Expand Up @@ -234,14 +237,13 @@ private function outputJson() {
}

private function genAudio($genType){
global $config;
switch($genType){
case 'mus':
$minRange = 1;
$unExistingFolder = '';
if($config['enableMusic'] === true) {
if($this->config['enableMusic']) {
for($i = 0; $i < $this->musToGen; $i++) {
$this->easter($config['easterMusRarity'], $this->debug, 'music');
$this->easter($this->config['easterMusRarity'], $this->debug, 'music');
if($this->musPerEvent === true) {
$currentMusFolder = $this->AbsolutePath.'/'.$this->eventNow.'/'.$this->musMountPoint.$this->easter;
} else {
Expand Down Expand Up @@ -295,9 +297,9 @@ private function genAudio($genType){
case 'snd':
$minRange = 1;
$unExistingFolder = '';
if($config['enableVoice'] === true) {
if($this->config['enableVoice']) {
for($i = 0; $i < $this->sndToGen; $i++) {
$this->easter($config['easterSndRarity'], $this->debug, 'sound');
$this->easter($this->config['easterSndRarity'], $this->debug, 'sound');
$currentSoundFolder = $this->AbsolutePath.'/'.$this->eventNow.'/'.$this->sndMountPoint.$this->seasonNow.$this->dayTimeNow.$this->easter;
if(is_dir($currentSoundFolder)) {
$this->sndFilesNum = count(filesInDir::filesInDirArray($currentSoundFolder, '.mp3'));
Expand Down Expand Up @@ -414,17 +416,16 @@ function checkPeriod($key, $value, $dayToday){
}

private function easter($chance, $debug = false, $of) {
global $config;
$minRange = 1;
$maxRange = 1000;
$easterChance = mt_rand($minRange, $maxRange);
switch($of){
case 'sound':
$confRarity = $config['easterSndRarity'];
$confRarity = $this->config['easterSndRarity'];
break;

case 'music':
$confRarity = $config['easterMusRarity'];
$confRarity = $this->config['easterMusRarity'];
break;
}
if ($easterChance <= $chance){
Expand Down Expand Up @@ -535,15 +536,6 @@ private function genRange($type, $range){
return $RandSoundFile;
}

private function IncludestartUpSoundModules(){
global $config;
$modulesDir = INCDIR.'startupsound';
if(!is_dir($modulesDir)){
mkdir($modulesDir);
}
functions::includeModules($modulesDir, $config['modulesDebug']);
}

/* FilesWork */
private function readEventFile(){
$data = file_get_contents($this->cacheFilePath);
Expand Down
7 changes: 7 additions & 0 deletions foxxey/etc/authorise.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[authorise]
checkHWID=1
geoIPcheck=1
useAntiBrute=1
getBalance=1
foxChecking=1

12 changes: 12 additions & 0 deletions foxxey/etc/mail.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[startupsound]
encoding=UTF-8
admin_mail[email protected]
mail_title=Foxesworld
mail_metod=smtp
smtp_host=smtp.yandex.ru
smtp_port=465
smtp_user[email protected]
smtp_pass=dvhbdxutiscpbmof
smtp_secure=ssl
smtp_mail[email protected]

12 changes: 0 additions & 12 deletions foxxey/etc/config.php → foxxey/etc/main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@
/* Logging */
'authLog' => FILES_DIR.'/logs/AuthLog.log',
'errorLog' => FILES_DIR.'/logs/Errors.log',

/* E-mail */
'encoding' => 'UTF-8',
'admin_mail' => '[email protected]',
'mail_title' => 'Foxesworld',
'mail_metod' => 'smtp',
'smtp_host' => 'smtp.yandex.ru',
'smtp_port' => '465',
'smtp_user' => '[email protected]',
'smtp_pass' => 'dvhbdxutiscpbmof',
'smtp_secure' => 'ssl',
'smtp_mail' => '[email protected]',

/* Database Settings */
'db_host' => 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion foxxey/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if(!defined('FOXXEY')) {
die ('{"message": "Not in FOXXEY thread"}');
} else {
require ($_SERVER['DOCUMENT_ROOT'].'/foxxey/etc/config.php');
require ($_SERVER['DOCUMENT_ROOT'].'/foxxey/etc/main.cfg');
require (SITE_ROOT.'/initFunctions');
}

Expand Down
Loading

0 comments on commit 30a0612

Please sign in to comment.