Skip to content

Commit

Permalink
Authorize.class Fix & Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
AidenF0X committed Aug 1, 2021
1 parent 98d1ee3 commit 9fbc99d
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 50 deletions.
3 changes: 1 addition & 2 deletions foxxey/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
'debugStartUpSound' => false,
'antiBruteDebug' => false,
'randTextsDebug' => false,
'debugStartUpSound' => false,

/* AUTHORISATION */
/* AUTHORISATION Modules */
'checkHWID' => true,
'geoIPcheck' => true,
'useAntiBrute' => true,
Expand Down
63 changes: 40 additions & 23 deletions foxxey/scripts/functions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-----------------------------------------------------
File: functions,class.php
-----------------------------------------------------
Version: 0.1.4.1 Experimental
Version: 0.1.4.2 Experimental
-----------------------------------------------------
Usage: A bunch of functions
=====================================================
Expand Down Expand Up @@ -51,21 +51,6 @@ public function getUserData($login,$data){
}
return $answer;
}

public function passwordReHash($pass, $realPass, $realName){
global $config;
//$db = new db($config['db_user'],$config['db_pass'],$config['db_database']);
if (password_needs_rehash($realPass, PASSWORD_DEFAULT)) {
session_regenerate_id();
$this->realPass = password_hash($this->pass, PASSWORD_DEFAULT);
$new_pass_hash = 'password='.$this->db->safesql($realPass).', ';
} else {
$new_pass_hash = '';
}

$hash = functions::generateLoginHash();
$this->db->run("UPDATE LOW_PRIORITY dle_users SET ".$new_pass_hash." hash='".$hash."', lastdate='".CURRENT_TIME."' WHERE name='".$realName."'");
}

/* STATIC FUNCTIONS (NO DB NEEDED)*/

Expand All @@ -85,30 +70,50 @@ static function generateLoginHash(){
return $hash;
}

public static function passwordReHash($pass, $realPass, $realName){
global $config;
$db = new db($config['db_user'],$config['db_pass'],$config['db_database']);
if (password_needs_rehash($realPass, PASSWORD_DEFAULT)) {
session_regenerate_id();
$this->realPass = password_hash($this->pass, PASSWORD_DEFAULT);
$new_pass_hash = 'password='.$db->safesql($realPass).', ';
} else {
$new_pass_hash = '';
}

$hash = functions::generateLoginHash();
$db->run("UPDATE LOW_PRIORITY dle_users SET ".$new_pass_hash." hash='".$hash."', lastdate='".CURRENT_TIME."' WHERE name='".$realName."'");
}

public static function includeModules($dirInclude, $debug = false){
$count = 1;
$IncludingText = '';
$dir = opendir($dirInclude);
if($debug === true){
echo '<div style="width: fit-content;"><b>Modules to include: </b> <hr style="margin: 0;">';
echo '<div style="width: fit-content; margin: 0px 5px 15px;"><b>Modules to include: </b> <hr style="margin: 0;">';
}
while($file = readdir($dir)){
if($file == '.' || $file == '..'){
continue;
} else {
if(!is_dir($dirInclude.'/'.$file)) {
if(strpos($file, '-')) {
$moduleName = explode ('-', $file);
$IncludingText = ' SubModule of - '.$moduleName[0];
}

if(strpos($file, 'module') !== false) {
require ($dirInclude.'/'.$file);

if($debug === true){
echo "<b>".$count."</b> Including ".$file."<br>";
echo "<b>".$count."</b>".$IncludingText." Including ".$file."<br>";
$count ++;
}

} else {

if($debug === true){
echo "<b>".$count."</b> ".$file." was not included as not the valid <br>";
echo "<b>".$count."</b>".$IncludingText.' '.$file." was not included as not the valid <br>";
}
}
}
Expand Down Expand Up @@ -149,6 +154,18 @@ public static function getUserName(){
return $name;
}

public static function wrongHWIDmessage(){
global $config;
if(class_exists('randTexts')) {
$randTexts = new randTexts('wrongHWID', $config['randTextsDebug']);
$name = $randTexts->textOut();
} else {
echo '{"message": "Module randTexts not found!", "desc": "Can`t say user how wrong he is!"},';
$name = 'Incorrect HWID';
}
return $name;
}

public static function checkTime ($timestamp) {
if($timestamp) {
switch ($timestamp){
Expand All @@ -170,7 +187,7 @@ public static function display_error($error ='No errors', $error_num = 100500, $
$error = htmlspecialchars($error, ENT_QUOTES, 'ISO-8859-1');
$trace = debug_backtrace();

$level = 0;
$level = 1;
if ($trace[1]['function'] == "query" ) $level = 1;
$trace[$level]['file'] = str_replace(ROOT_DIR, "", $trace[$level]['file']);

Expand Down Expand Up @@ -220,9 +237,9 @@ public static function display_error($error ='No errors', $error_num = 100500, $
<div style="width: 700px;margin: 20px; border: 1px solid #D9D9D9; background-color: #F1EFEF; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3); -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3); box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);" >
<div class="top" >MySQ: Error! '.$config['webserviceName'].'</div>
<div class="box" ><b>MySQL error</b> in file: <b>'.$trace[$level]['file'],'</b> at line <b>'.$trace[$level]['line'].'</b></div>
<div class="box" >Error Number: <b>'.$error_num.'</b></div>
<div class="box" >The Error returned was: <b>'.$error.'</b></div>
<div class="box" ><b>SQL query:</b><br />'.$query.'</div>
<div class="box" >Error Number: <b> '.$error_num.'</b></div>
<div class="box" >The Error returned was: <b> '.$error.'</b></div>
<div class="box" ><b>SQL query:</b> '.$query.'</div>
</div>
</body>
</html>
Expand Down
26 changes: 15 additions & 11 deletions foxxey/scripts/modules/authoriseModules/Auth-module_geoIP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
-----------------------------------------------------
https://Foxesworld.ru/
-----------------------------------------------------
Copyright (c) 2016-2020 FoxesWorld
Copyright (c) 2016-2021 FoxesWorld
-----------------------------------------------------
This code is private
-----------------------------------------------------
File: geoIP.class.php
-----------------------------------------------------
Version: 0.0.5 Alpha
Version: 0.1.6 Alpha
-----------------------------------------------------
scanning user's ip
Usage: Scanning user's ip
=====================================================
*/
if(!defined('Authorisation')) {
Expand All @@ -25,6 +25,7 @@ class geoPlugin extends Authorise {

//the geoPlugin server
var $host = 'http://www.geoplugin.net/php.gp?ip={IP}&base_currency={CURRENCY}';
private static $db;

var $currency = 'USD';
var $ip = null;
Expand All @@ -40,13 +41,15 @@ class geoPlugin extends Authorise {
var $currencyCode = null;
var $currencySymbol = null;
var $currencyConverter = null;

private static $Logger;

/**
* geoPlugin constructor.
* @param null $ip
*/
function __construct($ip = null) {
global $_SERVER;
global $_SERVER, $config;

if (is_null($ip)) {
$ip = $_SERVER['REMOTE_ADDR'];
Expand All @@ -57,6 +60,8 @@ function __construct($ip = null) {
$data = array();
$response = $this->fetch($host);
$data = unserialize($response);
geoPlugin::$db = new db($config['db_user'],$config['db_pass'],$config['dbname_launcher']);
geoPlugin::$Logger = new Logger('AuthLog');

$this->ip = $ip;
$this->city = $data['geoplugin_city'];
Expand Down Expand Up @@ -126,19 +131,17 @@ private function nearby($radius=10, $limit=null) {
private static function getIP($ip,$ipLocation,$ipRegion,$log=false){
global $config;
if($ip){
$db = new db($config['db_user'],$config['db_pass'],$config['dbname_launcher']);
if(!isset($_COOKIE['ipAdded']) && !isset($_SESSION['ipAdded'])){
$query = "SELECT * FROM `ipDatabase` WHERE ip = '$ip'";
$data = $db->getValue($query);
$data = geoPlugin::$db->getValue($query);
if (!isset($data) || $data === false) {
//$date="[".date("d m Y H:i")."] ";
if(!$ipLocation){
$ipLocation = 'Ниоткудинск';
}
if(!$ipRegion){
$ipRegion = 'Страна дураков';
}
$db->run("INSERT INTO `ipDatabase`(`ipLocation`, `ipRegion`, `ip`) VALUES ('$ipLocation','$ipRegion','$ip')");
geoPlugin::$db->run("INSERT INTO `ipDatabase`(`ipLocation`, `ipRegion`, `ip`) VALUES ('$ipLocation','$ipRegion','$ip')");
geoPlugin::addCityCount($ipRegion);
if($log === true){
echo 'Adding '.$ip.' - '.$ipLocation.'('.$ipRegion.') '.'to IP database';
Expand All @@ -165,15 +168,16 @@ private static function getIP($ip,$ipLocation,$ipRegion,$log=false){

private static function addCityCount($city){
global $config;
$db = new db($config['db_user'],$config['db_pass'],$config['dbname_launcher']);
$query = "SELECT * FROM ipCity WHERE cityName = '$city'";
$data = $db->getValue($query);
$data = geoPlugin::$db->getValue($query);

if(!isset($data) || $data === false){
static::$Logger->WriteLine('Adding `'.$city.'` Wow new login city!');
$query = "INSERT INTO `ipCity`(`cityName`) VALUES ('$city')";
} else {
static::$Logger->WriteLine('Oh, another one from `'.$city.'`... Well, I know what to do with you..');
$query = "UPDATE `ipCity` SET `cityCount`= cityCount+1 WHERE cityName = '$city'";
}
$db->run($query);
geoPlugin::$db->run($query);
}
}
Loading

0 comments on commit 9fbc99d

Please sign in to comment.